## Hex form in cobol

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

### Hex form in cobol

I have hex form 102D and what is the actual value? how we can find it?
Praveen5526

Posts: 10
Joined: Sat Apr 21, 2012 6:13 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Hex form in cobol

see here for all You might want to know about number representation

http://publibz.boulder.ibm.com/cgi-bin/ ... 0504121320
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator

Posts: 2978
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 160 times

### Re: Hex form in cobol

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.
Robert Sample
Global moderator

Posts: 3686
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 274 times

### Re: Hex form in cobol

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.
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

### Re: Hex form in cobol

1 ===== 4096
0 ===== 0
2 ===== 32
D ===== ( - )Negative
----------
actual value = - 4128

Correct me if I am wrong.
Praveen5526

Posts: 10
Joined: Sat Apr 21, 2012 6:13 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Hex form in cobol

You are wrong
( hint... You are mixing binary and packed representations )

review for the umpteenth time the packed concepts in the manual I pointed You to
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator

Posts: 2978
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 160 times

### Re: Hex form in cobol

You are wrong. The value of those hexadecimal digits is either -102 or +4141, depending.
Robert Sample
Global moderator

Posts: 3686
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 274 times

### Re: Hex form in cobol

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.
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

### Re: Hex form in cobol

I got it now.. Thank u all. Thank u somuch
Praveen5526

Posts: 10
Joined: Sat Apr 21, 2012 6:13 pm
Has thanked: 0 time
Been thanked: 0 time