Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
linc

New User

Joined: 25 Aug 2008
Posts: 25
Location: china

Posted: Mon Aug 31, 2009 9:04 pm    Post subject: ROUND function in PL1

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.

prino

Senior Member

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

 Posted: Mon Aug 31, 2009 9:48 pm    Post subject: Because you do not use scaled FIXED BIN in PL/I. If you still want to use them, live with the consequences.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8344
Location: Dubuque, Iowa, USA

Posted: Mon Aug 31, 2009 10:38 pm    Post subject:

 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us