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. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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