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 OF PERCENTAGES IN COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: ROUNDING OF PERCENTAGES IN COBOL
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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