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

Author Message
SB

New User

Joined: 25 Apr 2005
Posts: 1

 Posted: Fri May 06, 2005 3:46 pm    Post subject: ROUNDING OF PERCENTAGES IN COBOL I want to get the percentage rounded in cobol to the nearest two decimal places. The following is the syntax of the percentage calculation I have used. COMPUTE A ROUNDED = (B/C)*100 Where A,B and C are defined as 05 A VALUE 0 COMP-3 PIC S9(4)V9(3). 05 B VALUE 0 COMP-3 PIC S9(9). 05 C VALUE 0 COMP-3 PIC S9(11). for eg if the value of B = 10,616 and C=11,418 the result should be 92.98 but I am getting 92.97. But the result is not rounded. Could any one please guide me what could be the mistake I am committing.

notonly4u

New User

Joined: 26 Apr 2005
Posts: 87

 Posted: Fri May 06, 2005 4:00 pm    Post subject: Dear SB, Try this one.... compute A rounded to ceiling = (B/C)*100 Hope this will work.... If it is not pls let me know. Regards Tanden
notonly4u

New User

Joined: 26 Apr 2005
Posts: 87

 Posted: Fri May 06, 2005 4:05 pm    Post subject: If you want more info... Methods of Rounding There are five methods of rounding. The name in square brackets is how they are referred a) Round toward minus infinity [Ceiling] b) Round toward plus infinity [Floor] c) Round toward zero [Truncate] d) IEEE round to nearest [Nearest-unbiased]. "In the case of a value exactly half-way between two neighboring value, select the 'even' one. e) Traditional round to nearest [Nearest] Regards Tanden
notonly4u

New User

Joined: 26 Apr 2005
Posts: 87