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

Rounded option in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 12, 2012 2:58 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Apr 13, 2012 1:28 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 13, 2012 1:50 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


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 SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top