Electronic – IEEE-754 Floating Point Converter

armckeilmicrocontroller

I have in hexadecimal representation a IEEE-754 Floating Point:

uint32_t _u_IEEE_754 = 0x41100000; //9.0

The decimal representation is: 9.0

I am working in C under embedded system.

I want to get the integer and decimal part separately, from the number in hexadecimal. I can't use floating point. I have no idea where to start. Which idea would be of great help to me.

Best Answer

Wikipedia has a nice page on the floating point format (the various IEEE-754 ones).

0x41100000

0b010000010001000000....

0 10000010 001000000....

Implied 1

0 10000010 1.001000000....

0x82 = 130

0 130 1.0010000

sign bit is zero so positive number

2 to the exponent 130-127 = 2 to the power 3.

So we move the "decimal" (binary) point over 3

1.001000000....
10.01000000....
100.1000000....
1001.000000....

so

0x41100000

is 1001.00000......

which is 9.0

Quite simple when you look at the format (for normal encodings):

(-1)^sign x 2^(exponent-127) x 1.fraction
Related Topic