View previous topic :: View next topic
|
Author |
Message |
selvamsrinivasan85
New User
Joined: 09 Aug 2010 Posts: 33 Location: Chennai
|
|
|
|
Hi all,
I am receiving a 10 byte hex value (like X'808E640000') in a file. Corresponding layout has a variable, defined as X(5).
Now i am supposed to convert that hex value to a decimal value of 12 bytes (like 552144732160).
How can i achieve this?. Since its a 10 byte, unable to use COMP.
Throw some light on this. I will try at my end. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
I don't know if there is a COBOL function for this, but it should be easy enough to write the code to multiply each hex-digit's value by the value of its position and then add them up. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2133 Location: USA
|
|
Back to top |
|
|
selvamsrinivasan85
New User
Joined: 09 Aug 2010 Posts: 33 Location: Chennai
|
|
|
|
Hi Phil,
Thanks for the suggestion. Will give a try on that.
Hi Sergeyken,
If I declare as 9(9) comp-5, it occupies 4 bytes only and the last bytes is getting displayed on next variable and if i declare 9(10), it occupies 8 bytes. It looks like COMP and COMP-5 doesn't have any difference here. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2133 Location: USA
|
|
|
|
selvamsrinivasan85 wrote: |
Hi Phil,
Thanks for the suggestion. Will give a try on that.
Hi Sergeyken,
If I declare as 9(9) comp-5, it occupies 4 bytes only and the last bytes is getting displayed on next variable and if i declare 9(10), it occupies 8 bytes. It looks like COMP and COMP-5 doesn't have any difference here. |
You MUST declare your intermediate PIC 9(12) COMP-5 field (8 bytes), and populate its lower part with your initial X(5) - via REDEFINE, or any other trick. |
|
Back to top |
|
|
|