Computer question: little-endian and two's complements

Hello,

I’m trying to convert a 4-byte IEEE 745 floating point in an little-endian machine
(Intel) back into a format readable by humans. According to a little conversion program, the bit pattern (in hex):

80BEBF39 (with 80 at the lowest address)

corresponds to:

3.6572292e-04

I just can’t seem to get that result when I convert by hand. I start by converting
the number back to big-endian (39BFBE80); then convert that to binary
(111001101111111011111010000000); and then isolate the fractional
part of the number, bits 9-31, (101111111011111010000000); and then
doing a reverse two’s complement by inverting all bits and adding 1
(10000000100000110000000); and finally convert that number back to
decimal (4211072). As you can see, what I get is different from what
I’m expecting (36572292). Any programmers out there can help me?

According to this site, you took the wrong bits (bits 9-31 actually starts at the tenth bit), and you’re converting the fractional part wrong.

39BFBE80 = 0011 1001 1011 1111 1011 1110 1000 0000

Break it into the 3 parts

Sign Bit (Bit 0) = 0
Exponent (Bits 1-8) = 0111 0011
Fractional (Bits 9-31) = 011 1111 1011 1110 1000 0000

The linked site says you add a “1.” to the front of the fractional part, then convert it. Nothing about taking 2’s complement.

I’ll stop there because 1.01111111011111010000000 isn’t a fun conversion. First position after the decimal is 1/2, next is 1/4, next is 1/8 etc.

On preview, you can put your decimal value into this site and you’ll see the breakdown (use the rounded button to get your exact one).