English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

More on I want to display the 'hex value' of a packed decimal field in COBOL.?
I want to use this 'hex value' further in my code to do some validation. I am aware how to view data in hex format by giving the 'hex on' command on the TSO command line.

2006-10-15 16:35:58 · 2 answers · asked by smita3010 1 in Computers & Internet Programming & Design

2 answers

Well, this may not be the help you wanted, but I believe that it will serve the purpose. Remember your basic mathematics: Any value expressed in one number system can be expressed in another number system with a different base.

That is in fact very much the case here. You'd like to see it as a hexadecimal, but FF hexadecimal is exactly equal to 255 decimal or 11111111 binary or 377 octal. And, in fact, all numbers used by the system will be binary. Not trying to rain on your parade, but why not use the *DECIMAL EQUIVALENT* in the correct size data to represent the hexadecimal for the comparison? I promise, the computer won't care.

View it any way you like, but a number is exactly equal to that number and only that number, regardless of how you choose to express it.

2006-10-16 05:19:37 · answer #1 · answered by Anonymous · 0 0

01 binary-number s9(4) comp value 15.
01 text-binary-number redefines binary-number.
03 filler pic x.
03 test-unsigned-value pic x.

01 packed-number s9(3) comp-3.
01 text-packed-number redefines packed-number.
03 filler pic x.
03 packed-sign pic x.
procedure division.

if test-unsigned-value and packed-sign equals test-unsigned-value then
...
end-if.

That should work for unsigned values.
set the binary value to 13 for negative and 12 for positive.

And don't forget to close your previous questions and allocate 10 points!!!

2006-10-17 03:23:17 · answer #2 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers