Page 1 of 1

COMP-1 And Comp-2 representation

PostPosted: Sat Jun 05, 2010 6:40 pm
by coollearner
Hi All,

I have referred the following link
http://publibz.boulder.ibm.com/cgi-bin/ ... 0820210412

in this link :

Internal floating point
COMP-1
+ 1234
43 4D 20 00

- 1234
C3 4D 20 00

COMP-2
+ 1234
43 4D 20 00 00 00 00 00

- 1234
C3 4D 20 00 00 00 00 00

I want to know how the conversion happened?
The hexvalue of 1234 is 4D2. How did the 43 4D 20 00 got generated. Please explain

Re: COMP-1 And Comp-2 representation

PostPosted: Sat Jun 05, 2010 7:15 pm
by enrico-sorichetti
how do You expect to make a career in it with such a lack of ingenuity :D

please reread and uderstand the manual or better a bit of number representation theory
comp-1 and comp-2 as the manual says are floating point representations

see the pattern for binary representation of a positive 1234 ,
search for a similar pattern in the comp-1 representation
and meditate on the meaning of mantissa and exponent for floating point representation

Re: COMP-1 And Comp-2 representation

PostPosted: Sat Jun 05, 2010 8:01 pm
by Robert Sample
From the very manual that you have a link to in your post:

1.3.4.6 Internal floating-point (COMP-1 and COMP-2) items

COMP-1 refers to short floating-point format and COMP-2 refers to long floating-point format, which occupy 4 and 8 bytes of storage, respectively. The leftmost bit contains the sign and the next 7 bits contain the exponent; the remaining 3 or 7 bytes contain the mantissa.

COMP-1 and COMP-2 data items are stored in zSeries® hexadecimal format.