View previous topic :: View next topic
|
Author |
Message |
ramco_sita
New User
Joined: 25 Jun 2007 Posts: 40 Location: chennai
|
|
|
|
would like to how to use exponent in compute statements in cobol.
when we used ** it gets compiled but the value is not returned to that computed field.
anyone who has done this please give your recommendations |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Please post sample of your code so that we can help.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
This
Quote: |
we used ** it gets compiled but the value is not returned |
should work. If you post your variables and the procedure code in question, we can offer suggestions.
Also, post the values used in the calculation and the result when those values are used. |
|
Back to top |
|
|
ramco_sita
New User
Joined: 25 Jun 2007 Posts: 40 Location: chennai
|
|
|
|
The sample code
01 ws-num1 pic 9(9)v9(2).
Compute ws-num1 = (1+ 10/100) ** 5 |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
And you are not getting 1.61? |
|
Back to top |
|
|
Raghavendra P K
New User
Joined: 24 Aug 2007 Posts: 24 Location: bangalore
|
|
|
|
Hi Sita,
the code works fine, here is the code and the output that i have got.
01 WS-NUM1 PIC 9(09)V9(02).
01 WS-NUM2 PIC 9(09).9(02).
Procedure division.
INITIALIZE WS-NUM1.
COMPUTE WS-NUM1 = (1 + 10/100)**5.
MOVE WS-NUM1 TO WS-NUM2.
DISPLAY 'WS-NUM2 :' WS-NUM2.
The Output:
WS-NUM2 :000000001.61 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Try this
Quote: |
Compute ws-num1 = (1+ 10/100) ** 5 |
using decimal places in at least ont of these "(1+ 10/100)" operands, not just the answer. |
|
Back to top |
|
|
Raghavendra P K
New User
Joined: 24 Aug 2007 Posts: 24 Location: bangalore
|
|
|
|
Hi Dick,
I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Raghavendra P K wrote: |
the code works fine, here is the code and the output that i have got. |
Raghavendra P K wrote: |
I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs. |
Huh? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Raghavendra P K wrote: |
Hi Dick,
I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs. |
Please try following-
Quote: |
COMPUTE WS-NUM1 = (1.00 + 10 / 100) ** 5. |
|
|
Back to top |
|
|
ramco_sita
New User
Joined: 25 Jun 2007 Posts: 40 Location: chennai
|
|
|
|
Thanks ! it worked for us in cobol.. |
|
Back to top |
|
|
|