|
|
| Author |
Message |
alluri12
New User
Joined: 15 Aug 2006 Posts: 24
|
|
|
|
Hi guys,
In a program I am using
01 WS-VALUE1 PIC9(10) VALUE 2336440320
01 WS-COMPUTED-VALUE PIC9(02)V9(03)
Compute WS-COMPUTED-VALUE ROUNDED = (WS-VALUE1/3999999999)*100
The result i am getting is 5841.
I am expecting is 58.41
Could you please provide me some solution for this
Thanks |
|
| Back to top |
|
 |
References
|
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 3304 Location: Charlotte,NC USA
|
|
|
|
| My result using your code is 58.410. |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8729 Location: 221 B Baker St
|
|
|
|
Hello,
I'd recomend placing periods at the end of your statements.
In this
| Code: |
| 01 WS-COMPUTED-VALUE PIC9(02)V9(03) |
field, there is no decimal point defined - what you have is an implied decimal, not an explicit one. If you wan to see the '.', you must include it in the definition. |
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 2977 Location: Tucson AZ
|
|
|
|
| How do you know you are getting 5841 rather than 58.41? |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8729 Location: 221 B Baker St
|
|
|
|
Hello again,
With the implied and then the explicit decimal point
| Code: |
01 WS-VALUE1 PIC 9(10) VALUE 2336440320.
01 WS-COMPUTED-VALUE PIC 9(02)V9(03).
01 WS-DOT-VALUE PIC 9(02).9(03).
COMPUTE WS-COMPUTED-VALUE ROUNDED =
(WS-VALUE1/3999999999)*100.
DISPLAY WS-COMPUTED-VALUE.
MOVE WS-COMPUTED-VALUE TO WS-DOT-VALUE.
DISPLAY WS-DOT-VALUE.
|
you get
|
|
| Back to top |
|
 |
alluri12
New User
Joined: 15 Aug 2006 Posts: 24
|
|
|
|
Thanks guys for replying so fast. It helps.
Dick, you explaination was crystal clear... thankyou |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8729 Location: 221 B Baker St
|
|
|
|
You're welcome  |
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 2977 Location: Tucson AZ
|
|
|
|
| dick scherrer wrote: |
| With the implied and then the explicit decimal point |
Dang, ya beat me to it...I was heading there, I was just fishing for confirmation.....
Good call!  |
|
| Back to top |
|
 |
|
|