Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RMCOBOL round up 1

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
How do I round a PIC 9(8)V9(02)?

Say, I have something that is a value of 10.01 and I need it rounded to 11.00

Thanks.
-David
 
David,

This is not standard COBOL rounding.
Code:
01  a-num  pic 9(8)v99.
01  redefines a-num.
    03 a-integer    pic 9(8).
    03 a-fraction   pic 99.
...
if a-fraction not = zero
    add 1 to a-integer
    move 0 to a-fraction
end-if.



Tom Morrison
 
Why not define the result as a whole number and compute it using the rounding option?

Code:
01  WS-ROUNDED-RESULT    PIC S9(9).
...
COMPUTE WS-ROUNDED-RESULT ROUNDED = ...

Regards.

Glenn
 
Oops. Disregard. I was asleep at the wheel!

Glenn
 
Glen, as Tom Morrison said, what David wants is not standard COBOL rounding.
 
Why not combine Glenn's and Frederico's ideas?

03 AMOUNT PIC 9(08)V99.
03 RESULT PIC 9(09).

COMPUTE RESULT = AMOUNT + .99
 
Thanks.
Tom's solution will work. They just want it rounded up if the decimal digits are not equal 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top