Page 1 of 1

Hex form in cobol

PostPosted: Sun Apr 22, 2012 11:12 pm
by Praveen5526
I have hex form 102D and what is the actual value? how we can find it?

Re: Hex form in cobol

PostPosted: Sun Apr 22, 2012 11:14 pm
by enrico-sorichetti
see here for all You might want to know about number representation

http://publibz.boulder.ibm.com/cgi-bin/ ... 0504121320

Re: Hex form in cobol

PostPosted: Mon Apr 23, 2012 12:25 am
by Robert Sample
You DO realize, I hope, that there is more than one answer to your question? The answer depends upon the USAGE clause for the variable in question. If the variable is COMP-3, the value is negative. If the variable is COMP, the value is positive. The actual values you can find, if you follow enrico's link.

Re: Hex form in cobol

PostPosted: Mon Apr 23, 2012 3:16 am
by BillyBoyo
That's the very first sections in chapters 7 and 8 from enrico's post.

Why can't you find how the field is defined which gives you that value? That will help you a lot.

Re: Hex form in cobol

PostPosted: Tue Apr 24, 2012 12:03 pm
by Praveen5526
1 ===== 4096
0 ===== 0
2 ===== 32
D ===== ( - )Negative
----------
actual value = - 4128


Correct me if I am wrong.

Re: Hex form in cobol

PostPosted: Tue Apr 24, 2012 12:09 pm
by enrico-sorichetti
You are wrong :geek:
( hint... You are mixing binary and packed representations )

review for the umpteenth time the packed concepts in the manual I pointed You to

Re: Hex form in cobol

PostPosted: Tue Apr 24, 2012 2:35 pm
by Robert Sample
You are wrong. The value of those hexadecimal digits is either -102 or +4141, depending.

Re: Hex form in cobol

PostPosted: Tue Apr 24, 2012 4:58 pm
by BillyBoyo
What is the source of your hex value? When you see that in "memory" or a dump somewhere, it is not necessarily even "a number". It could be an instruction. It could be a chunk of storage that contains that value for some reason (it could be two individual bytes whose values are related, or unrelated, one byte may just contain a bit pattern, or any number of things). You might have picked up part of an address, so the "value" is actually longer, and you don't know where that value is, so can't know what it represents.

In short, to tell what "value" a particular hex representation has, you have to know specifically how it is used in that particular instance.

You can't look at a hex value in isolation and say "that has this value in decimal" because what you are looking at may be the hex of something you've previously seen as a numeric value, but in this case turns out not to be any sort of "number" at all.

Re: Hex form in cobol

PostPosted: Tue Apr 24, 2012 5:56 pm
by Praveen5526
I got it now.. Thank u all. Thank u somuch