View previous topic :: View next topic
|
Author |
Message |
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
I am in a process of doing EPLI migration.
Can any one give solution for the below scenario
Code: |
dcl x fixed dec(8);
dcl y fixed bin(31);
x=x+y;
z=round(x,2) |
I have ended up s0ca (Fixed over flow) saying x is not in position to hold the value.
so I have changed like this
Code: |
dcl x fixed dec(15);
dcl y fixed bin(31);
x=x+y
z=round(x,2) |
but it is compilaton error as trying to do arithmetic operation with fixed bin(31) (variable y).
so I have changed
Code: |
dcl x fixed bin(31)
dcl y fixed bin(31);
x=x+y
z=round(x,2) |
but results were not accurate as they are using round function on x even I used dec builtin function like
below but ended up with inaccurate results.
Code: |
dcl x fixed bin(31)
dcl y fixed bin(31);
x=x+y
z=round(dec(x),2) |
|
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Why would you round two integers? |
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
Actually What I have given is just an example.
Infact it is like this
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
COBOL has very precise rules governing intermediate results that are not immediately obvious to the casual observer. Maybe PL/I has similar rules? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Don't use fixed bin (31) for things they were not designed for.
They were designed as INTEGERs, don't use them for anything else, you'll rue the consequences.
And RTFM about the rules for mixing FIXED DEC and FIXED BIN. |
|
Back to top |
|
|
|