I just want to Round of the Dollar Amount to its nearest 10 cents.
Say if i have $ 7.23 then i need to round off to $ 7.20
if i have $ 7.26 then i need to round off to $ 7.30
if i have $ - 7.26 then i need to round off to $ 7.30
if i have $ - 7.24 then i need to round off to $ 7.20
Rounded function in cobol is not working. Please help me is there any way to solve it.
Joined: 06 Jul 2010 Posts: 654 Location: Whitby, ON, Canada
It's actually very simple. Here is the explanation of how rounding works from the Cobol Language Reference:
After decimal point alignment, the number of places in the fraction of the result of an arithmetic operation is compared with the number of places provided for the fraction of the resultant identifier. When the size of the fractional result exceeds the number of places provided for its storage, truncation occurs unless ROUNDED is specified. When ROUNDED is specified, the least significant digit of the resultant identifier is increased by 1 whenever the most significant digit of the excess is greater than or equal to 5.
Study this for a while and the answer will become obvious.