Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Inaccurate results with Round function

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

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Fri Sep 11, 2009 7:48 pm    Post subject: Inaccurate results with Round function
Reply with quote

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
View user's profile Send private message

prino

Senior Member


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

PostPosted: Fri Sep 11, 2009 8:14 pm    Post subject:
Reply with quote

Why would you round two integers?
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Fri Sep 11, 2009 9:15 pm    Post subject: Reply to: Inaccurate results with Round function
Reply with quote

Actually What I have given is just an example.
Infact it is like this
Code:
round((x/z)*100,2)
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Sep 11, 2009 9:24 pm    Post subject:
Reply with quote

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
View user's profile Send private message
prino

Senior Member


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

PostPosted: Fri Sep 11, 2009 9:50 pm    Post subject:
Reply with quote

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
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 Weirdo results with JOINKEYS Balaryan DFSORT/ICETOOL 4 Wed Oct 18, 2017 9:04 pm
No new posts What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am
No new posts Vision results (also known as DYL-280) CaptBill CA Products 1 Tue Dec 20, 2016 3:35 am
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us