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
 
ROUND function in PL1

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

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Mon Aug 31, 2009 9:04 pm    Post subject: ROUND function in PL1
Reply with quote

I have a question for using ROUND function in PL1.Here is the example:
Code:

 fb1 fixed binary(31, 8),
 fb1 = 16.8750; 
round(16.8750, 2)=        17.00000

   


Can anybody tell me why is not equal to "16.88" ?Thanks very much.
Back to top
View user's profile Send private message

prino

Senior Member


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

PostPosted: Mon Aug 31, 2009 9:48 pm    Post subject:
Reply with quote

Because you do not use scaled FIXED BIN in PL/I. If you still want to use them, live with the consequences.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8195
Location: East Dubuque, Illinois, USA

PostPosted: Mon Aug 31, 2009 10:38 pm    Post subject:
Reply with quote

Quote:
Can anybody tell me why is not equal to "16.88" ?
Okay, you're wanting to know why a FIXED BINARY field is not rounding to decimal rules? Probably because it is rounding to binary rules.

16.8750 = 10000.111 in binary. Rounding to 2 binary digits (which is what you are telling it to do) adds .001 (1/2 of the last round digit) to your value, which gives 10001.0000 or 17. If you wanted it rounded to 16.88, you should have used FIXED DECIMAL instead of FIXED BINARY.
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 What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 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
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am

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