View previous topic :: View next topic |
Author |
Message |
jathampy Beginner
Joined: 21 Dec 2007 Posts: 15 Topics: 6 Location: UK
|
Posted: Wed Aug 02, 2023 11:13 am Post subject: Convert external floating point number to COMP-2 |
|
|
I have an input file that contain amount fields in exponential form like "-2.2204462782314e-16". I want to convert this into COMP-2 format.
Tried NUMVAL-F intrinsic function and the cobol compiler (Z/OS 4.2.0) giving compilation error "expected a function name, but found NUMVAL-F". However NUMVAL and NUMVAL-C intrinsic functions are working.
Any idea how to convert the exponential representation of numbers to COMP-2 internal floating point ? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Wed Aug 02, 2023 5:08 pm Post subject: |
|
|
jathampy,
Try this
Code: |
WORKING-STORAGE SECTION.
01 WS-INP-FLNUM PIC +V9(16)E+99 GLOBAL.
01 WS-INP-FLCHAR REDEFINES WS-INP-FLNUM.
05 A PIC X(20).
01 WS-OUT-FL COMP-2.
PROCEDURE DIVISION.
MOVE "-2.2204462782314E-16" TO A.
DISPLAY 'CHAR VALUE : ' A
MOVE WS-INP-FLNUM TO WS-OUT-FL
DISPLAY 'COMP VALUE : ' WS-OUT-FL
GOBACK.
|
Result from 6.xx compiler
Code: |
CHAR VALUE : -2.2204462782314E-16
COMP VALUE : -.22204462782314002E-15
|
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
jathampy Beginner
Joined: 21 Dec 2007 Posts: 15 Topics: 6 Location: UK
|
Posted: Sat Aug 05, 2023 3:47 am Post subject: |
|
|
Thanks Kolusu for providing the solution. I tried the solution but job failed with
Quote: | "IGZ0040S An invalid separate sign was detected in program" | while executing the move statement " MOVE WS-INP-FLNUM TO WS-OUT-FL"
We are using the old cobol compiler (Z/OS 4.2.0) and this will be upgraded only next year post Z/OS upgrade. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Thu Aug 10, 2023 10:06 am Post subject: |
|
|
jathampy,
Can you give this a try ?
Code: |
WORKING-STORAGE SECTION.
01 WS-INP-FLNUM PIC +V9(16)E+99 GLOBAL.
01 WS-INP-FLCHAR REDEFINES WS-INP-FLNUM.
05 A PIC X(21).
01 WS-OUT-FL COMP-2.
PROCEDURE DIVISION.
MOVE "-2.2204462782314E-16" TO A.
DISPLAY 'CHAR VALUE A : ' A
COMPUTE WS-OUT-FL = FUNCTION NUMVAL-F(A)
DISPLAY "COMP-2 Value is : " WS-OUT-FL
|
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
jathampy Beginner
Joined: 21 Dec 2007 Posts: 15 Topics: 6 Location: UK
|
Posted: Mon Aug 14, 2023 9:29 am Post subject: |
|
|
I tried NUMVAL-F before also and it's not working. The Other intrinsic functions NUMVAL and NUMVAL-C are working fine with the compiler version 4.2.0 V4R2 . When I use NUMVAL-F,it's giving compilation error:
Code: | IGYPS2130-S Expected a function-name, but found "NUMVAL-F". The "COMPUTE" statement was discarded. |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|