IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

ROUNDING OF PERCENTAGES IN COBOL


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
SB

New User


Joined: 25 Apr 2005
Posts: 1

PostPosted: Fri May 06, 2005 3:46 pm
Reply with quote

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.
Back to top
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Fri May 06, 2005 4:00 pm
Reply with quote

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
Back to top
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Fri May 06, 2005 4:05 pm
Reply with quote

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
Back to top
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Fri May 06, 2005 4:05 pm
Reply with quote

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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top