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

Author Message
Absinthia

New User

Joined: 10 Jan 2008
Posts: 36
Location: CHINA

 Posted: Fri Jan 16, 2009 2:52 pm    Post subject: How does the division operand determine decimals Hi, everyone. I met with a problem like below 05 X PIC S9(05)V99. 05 Y PIC S9(05)V99. 05 A PIC 9(4) 05 B PIC 9(4) Now A is 55, B is 365 COMPUTE X = A/B * 0.0012 * 5470 My question is ,what is the result of A/B, how does cobol determine the decimal points? for example, is the result 0.1506 or0.15068 or 0.15 or something? I only know if we do it like this Y = A/B ,the result will be determined by the PIC of Y. but don't the result when it's processed in the middle. Thanks in advance.

Absinthia

New User

Joined: 10 Jan 2008
Posts: 36
Location: CHINA

 Posted: Fri Jan 16, 2009 3:10 pm    Post subject: and if the definition of A and B is like this 05 A PIC 9(5) 05 B PIC 9(4) what will be the result?
km_abdullah

New User

Joined: 03 Nov 2008
Posts: 60

Posted: Fri Jan 16, 2009 3:22 pm    Post subject:

Hi Absinthia,

COBOL determines the decimal points based on the 'datatype' of resultant variable. The resultant variable stores the intermediate results in the formulae before computing the final result.

 Quote: COMPUTE X = A/B * 0.0012 * 5470

In the above case, the result of A/B is '0.15' (since X has 2 dec places) and that is taken into consideration.

Hope this helps!
Absinthia

New User

Joined: 10 Jan 2008
Posts: 36
Location: CHINA

 Posted: Mon Jan 19, 2009 7:13 am    Post subject: Thanks a lot, abdullah. It helps
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

Posted: Tue Jan 20, 2009 6:21 pm    Post subject:

 Quote: My question is ,what is the result of A/B, how does cobol determine the decimal points?
There's a manuals link at the top of the page. Click on the COBOL Programming Guide and pull up Appendix A. This entire appendix discusses how COBOL determines intermediate and final results of arithmetic operations.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Determine Region with max bandwidth f... seahawk789 COBOL Programming 3 Mon Feb 27, 2017 8:26 pm Identification Division anandgbe COBOL Programming 2 Sat May 28, 2016 11:51 am How to determine where is error in ab... jackzhang75 PL/I & Assembler 13 Fri Apr 15, 2016 2:01 am To determine the range on a Alphanume... Prasanth Kumar COBOL Programming 3 Mon Feb 15, 2016 9:35 am Starts DEBUGGING by Procedure Divisio... jackare Testing & Performance analysis 4 Sun Jan 10, 2016 10:37 pm

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