Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
dilip_bangalore

New User

Joined: 29 Sep 2011
Posts: 27
Location: India

 Posted: Thu Apr 12, 2012 10:56 am    Post subject: Rounded option in cobol Hi, Does rounded option in cobol for 12.95, gives next number 13 ? Regards, Dilip

Peter cobolskolan

Active User

Joined: 06 Feb 2012
Posts: 104
Location: Sweden

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

 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.
chandu ravichandra

New User

Joined: 10 Apr 2012
Posts: 6
Location: INDIA

 Posted: Thu Apr 12, 2012 2:38 pm    Post subject: Reply to: Rounded option in cobol Hi, It will round it to 13.. The result variable will have 13.....
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

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

 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.
PeterHolland

Global Moderator

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

 Posted: Fri Apr 13, 2012 1:28 pm    Post subject: And because of that the language Reference cant be used any more?
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Fri Apr 13, 2012 1:50 pm    Post subject: Reply to: Rounded option in cobol :-) How would you come to that conclusion, Peter? Second Peter, that is. In this thread, anyway. First Peter in our Hearts.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to display offset thru cobol prog... tvinodkumar7 CICS 1 Sun Apr 22, 2018 8:42 pm Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm COBOL MVS options BiswajitDG COBOL Programming 8 Fri Apr 06, 2018 12:35 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us