Single-precision floating points
- From: Christian Christmann <spamtrap@xxxxxxxxxx>
- Date: Wed, 21 Jun 2006 23:46:51 +0200
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
.
- Follow-Ups:
- Re: Single-precision floating points
- From: Benjamin David Lunt
- Re: Single-precision floating points
- From: spamtrap
- Re: Single-precision floating points
- Prev by Date: Having trouble posting?
- Next by Date: Re: Single-precision floating points
- Previous by thread: Text under VESA mode 0x118
- Next by thread: Re: Single-precision floating points
- Index(es):
Relevant Pages
|
|