Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Rounding off the rate value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sreeharithag

New User


Joined: 26 Apr 2010
Posts: 9
Location: chennai

PostPosted: Wed May 25, 2011 10:55 am    Post subject: Rounding off the rate value
Reply with quote

Hi,
My code has the computation of getting the rate value as below

COMPUTE RATE=AMOUNT * WEIGHT

I need to round off the RATE value here as below
Example:

When Rate = 12345.005 this value should get rounded off and result should be = 12345.01

Please help me out in this.

Thanks,
Haritha
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1722
Location: UK

PostPosted: Wed May 25, 2011 11:06 am    Post subject:
Reply with quote

Did you search the forum, manual, internet for rounding? There seems to be a thread that answers yoiur question and it was in progress since you started on the forum so you will have read it - you do read ALL posts do you not?.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Wed May 25, 2011 11:12 am    Post subject: Reply to: Rounding off the rate value
Reply with quote

and what should be the result for 12345.015

ask the powers of Your organization about the rounding rule be used

usually the round half to even rule is used

quoted from wikipedia under the fair use assumption
Round half to even
Quote:
A tie-breaking rule that is even less biased is round half to even, namely
If the fraction of y is 0.5, then q is the even integer nearest to y.
Thus, for example, +23.5 becomes +24, +22.5 becomes +22, −22.5 becomes −22, and −23.5 becomes −24.
This method also treats positive and negative values symmetrically, and therefore is free of overall bias if the original numbers are positive or negative with equal probability. In addition, for most reasonable distributions of y values, the expected (average) value of the rounded numbers is essentially the same as that of the original numbers, even if the latter are all positive (or all negative). However, this rule will still introduce a positive bias for even numbers (including zero), and a negative bias for the odd ones.
This variant of the round-to-nearest method is also called unbiased rounding (ambiguously, and a bit abusively), convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, or bankers' rounding. This is widely used in bookkeeping.
This is the default rounding mode used in IEEE 754 computing functions and operators.


the average of two numbers will be preserved
truncation
22.5 ==> 22
23.5 ==> 23
the averages
23 vs. 22.5

half to even
22.5 ==> 22
23.5 ==> 24
the averages
23 vs. 23

meditate better on the rules before worrying about the minutiae of the iomplentation !
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Prevent rounding of COMP-2 when displ... sijayapal COBOL Programming 5 Wed Apr 08, 2015 10:07 pm
No new posts Rounding the cents to zero dharmaraok COBOL Programming 9 Sat Jun 21, 2014 8:25 am
No new posts COST*RATE Vs MIPS Vs CPU Rohit Umarjikar DB2 10 Fri Apr 26, 2013 3:14 am
No new posts COBOL - ROUNDING OFF TO NEAREST 1 $ balaji81_k COBOL Programming 4 Wed Sep 26, 2012 12:18 pm
No new posts Calculate and rounding up value usin... Skolusu DFSORT/ICETOOL 23 Tue Apr 24, 2012 5:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us