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
 

 

Rounded option in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dilip_bangalore

New User


Joined: 29 Sep 2011
Posts: 27
Location: India

PostPosted: Thu Apr 12, 2012 10:56 am    Post subject: Rounded option in cobol
Reply with quote

Hi,

Does rounded option in cobol for 12.95, gives next number 13 ?

Regards,
Dilip
Back to top
View user's profile Send private message

Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Thu Apr 12, 2012 11:26 am    Post subject: Reply to: Rounded option in cobol
Reply with quote

Code:
If this is one of those "Interview questions"
    The answere is: Yes, and read the manual
Else
    The answere is: Test it, and read the manual
End If


This assumes the result variable is declared without decimals.
Back to top
View user's profile Send private message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Thu Apr 12, 2012 2:38 pm    Post subject: Reply to: Rounded option in cobol
Reply with quote

Hi,

It will round it to 13..
The result variable will have 13.....
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Thu Apr 12, 2012 2:58 pm    Post subject: Reply to: Rounded option in cobol
Reply with quote

Language Reference (emphasis added) wrote:
ROUNDED phrase
After decimal point alignment, the number of places in the fraction of the result of
an arithmetic operation is compared with the number of places provided for the
fraction of the resultant identifier.
When the size of the fractional result exceeds the number of places provided for its
storage, truncation occurs unless ROUNDED is specified. When ROUNDED is
specified
, the least significant digit of the resultant identifier is increased by 1
whenever the most significant digit of the excess is greater than or equal to 5.



I think this is a little unclear. The paragraph would be better split into two. Maybe like this would be clearer:

Quote:
When ROUNDED is specified, the least significant digit of the resultant identifier is increased by 1 whenever the most significant digit of the excess is greater than or equal to 5.

When the size of the fractional result exceeds the number of places provided for its storage, truncation occurs unless ROUNDED is specified.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2429
Location: Netherlands, Amstelveen

PostPosted: Fri Apr 13, 2012 1:28 pm    Post subject:
Reply with quote

And because of that the language Reference cant be used any more?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Fri Apr 13, 2012 1:50 pm    Post subject: Reply to: Rounded option in cobol
Reply with quote

:-)

How would you come to that conclusion, Peter? Second Peter, that is. In this thread, anyway. First Peter in our Hearts.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm


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