IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

ONCODE 310 FIXED DECIMAL OVERFLOW


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Sep 12, 2011 11:50 am
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Sep 12, 2011 12:33 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1315
Location: Vilnius, Lithuania

PostPosted: Mon Sep 12, 2011 8:31 pm
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
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: 1787
Location: Bloomington, IL

PostPosted: Mon Sep 12, 2011 9:55 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 13, 2011 12:37 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1315
Location: Vilnius, Lithuania

PostPosted: Tue Sep 13, 2011 1:20 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 13, 2011 3:22 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top