Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

ONCODE 310 FIXED DECIMAL OVERFLOW

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
swathykrishnan

New User


Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

PostPosted: Mon Sep 12, 2011 10:33 am    Post subject: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

Hi

I have 3 variables with the definition given below

A FIXED BIN(15,2)
B FIXED BIN(15,2)
C FIXED BIN(5,2)

And the the following operation will be performed on these variables

A=ROUND((B * (ROUND(PREC(C/100.5,4),3)),2)

This code will give ONCODE 310 when B is having 13 digits in integer part. It will work fine till B is having 12 digits in integer part. We can use MULTIPLY function to avoid this issue. But it will cause truncation of decimal fields. Is there any other way to fix this issue?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Sep 12, 2011 11:50 am    Post subject: Re: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

I don't think you have fully described your problem.

If the sub-calculation of C, for instance, returns a value of 1, are you saying you'd get an error with B having 13 digits before the decimal place?
Back to top
View user's profile Send private message
swathykrishnan

New User


Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

PostPosted: Mon Sep 12, 2011 12:17 pm    Post subject:
Reply with quote

Hi Bill

The value of C will be always always <=100. If its sub calculation gives 1 it wont create any issues. Say value of C as 12.55 and B=9874567654321.88 the program will abend with ONCODE 310.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Sep 12, 2011 12:33 pm    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

So, if you, in your data definition, have a maximum of 13 positions before the decimal place, and you have a 13 non-decimal-digit number, and you multiply by 10, you get 14 digits, which don't fit, so POP.

You definition should be made big enough to contain the maximum value that is reasonable for the program to handle.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Mon Sep 12, 2011 8:31 pm    Post subject:
Reply with quote

You do not, EVER, use "fixed bin (15,2)" variables in PL/I.

If you want to use fractions in PL/I you use FIXED DEC!

Given the numbers you post, 9874567654321.88 and 12.55, you also don't have a clue as to what a "fixed bin (15,2)" actually means, as neither of them can ever be stored into a variable of that type and precision.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Sep 12, 2011 9:36 pm    Post subject:
Reply with quote

you don't do it with cobol either.

lot of knuckleheads think binary computations are faster,
(even though z/os has hardware / middleware / decimal functions)
and all the bytes you can save with binary fields.

a lot of misconceptions and little understanding lead to problems like the ts has posted.

did the rastelle thumb a few years ago. did not know that it was you.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Mon Sep 12, 2011 9:55 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
lot of knuckleheads think binary computations are faster,
(even though z/os has hardware / middleware / decimal functions)

z/OS??? System/360 had microcoded decimal instructions in 1964.

These toy software engineers with experience limited to toy computers need to grow up before they try programming in the real world icon_mad.gif
Back to top
View user's profile Send private message
swathykrishnan

New User


Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

PostPosted: Tue Sep 13, 2011 11:44 am    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

Hi Prino.

That was a mistake from my side.. I am using FIXED DEC only...

Code:
A FIXED DEC(15,2)
B FIXED DEC(15,2)
C FIXED DEC(5,2)


In the example we can see B is having 13 digits integer and 2 digits decimal. And subcalculation of C will have 3 decimal part. So the result of multiplication will have 18 digits. At that time only the program will end with 310.
FLOAT DECIMAL will fix this issue. But ROUND is not working on FLOAT DEC. And if we move it to FIXED DEC it will take 15 digits from left and last 3 digits of decimal part will get truncated.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Sep 13, 2011 12:37 pm    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

Presumably PL/I has an equivalent to Cobol's ARITH(31) compiler option, if your problem is a plain lack of digits.

Unrelated, but with A being such a vast number, are you really sure your user is worried about +/- .01 from the final rounding?

It is unusual to me to see the rounding of the intermediate products. If that is what the user wants, OK.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Tue Sep 13, 2011 1:20 pm    Post subject: Re: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW
Reply with quote

Bill Woodger wrote:
Presumably PL/I has an equivalent to Cobol's ARITH(31) compiler option, if your problem is a plain lack of digits.

Code:
*process limits(fixeddec(15,31) fixedbin(31,63));

And don't be a smart-ass, and use

Code:
*process limits(fixeddec(31,31) fixedbin(63,63));
Back to top
View user's profile Send private message
swathykrishnan

New User


Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

PostPosted: Tue Sep 13, 2011 3:11 pm    Post subject:
Reply with quote

Hi Bill

Yes the user need it to get rounded for 2 digits even if its a vast number...
MULTIPLY or FLOAT DECIMAL will fix this issue... But we need to ROUND it...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Sep 13, 2011 3:22 pm    Post subject:
Reply with quote

Hi,

Did you see Prino's last post? If you need more digits than you are "allowed", use the compiler option he has posted to give yourself access to more digits. Then you can define your fields as big enough for your purposes, and ROUND it to your heart's content.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Pool Overflow in Mainframe ADABASE polymathtarun Java & MQSeries 4 Fri Jun 03, 2016 11:57 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us