Single-precision floating points



Hi,

a question on handling single-precision floating points.

Due to IEEE 754 a single-precision floating point value is represented as
a 32-bit value consisting of a sign bit (bit 31), a biased exponent (bits
30, 23) and the fraction part of the mantissa (bits 22 to 0).

In my C source code I have this variable initialization:
float f1 = 25.1;

Gcc generates assembly code that moves the value 25.1 into register eax:
movl $0x41c8cccd, %eax

However, when I convert the hex value mentioned above to binary, I get
1000001110010001100110011001101

As can be seen, also the MSB is set to '1' what actually would indicate a
negative value (since it's the sign bit). But my value is positive (25.1).

Can anyone shed some light on this?

And a second question: Does anyone one some C function examples that take
a floating value and return the corresponding 32-bit value according to
IEEE-754?

Thank you.
Chris

.



Relevant Pages

  • Re: Single-precision floating points
    ... Due to IEEE 754 a single-precision floating point value is represented as ... In my C source code I have this variable initialization: ... Gcc generates assembly code that moves the value 25.1 into register eax: ... Your hex converter isn't ...
    (comp.lang.asm.x86)
  • Re: Single-precision floating points
    ... Due to IEEE 754 a single-precision floating point value is represented as ... In my C source code I have this variable initialization: ... Gcc generates assembly code that moves the value 25.1 into register eax: ...
    (comp.lang.asm.x86)