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

ROUND function in PL1


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Aug 31, 2009 9:48 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Aug 31, 2009 10:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top