View previous topic :: View next topic
|
Author |
Message |
linc
New User
Joined: 25 Aug 2008 Posts: 25 Location: china
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|