Re: floating point representation



waltbrad wrote:
I'm posting here again seeking help on understanding floating point
numbers. I'm an absolute novice, struggling with ASM concepts, but I
am able to write the basic programs offered in AOA.

Now, with floating point I do understand how they are stored. For
instance the single precision has the low order 23 bits as a mantissa,
the next 8 bits up are the exponent, and the H.O. bit is the sign bit.

Not quite. There are 24 bits of mantissa in a normalized value, but only 23 are stored. Since the highest bit is always 1, it can be implied.


I understand the excess-bias and understand the exponent is a power of
2.

But for the life of me I cannot construct a number manually from it's
stored representation.

For instance: the number '7', has the hex representation of
40E0_0000

which translates to:

0100 0000 1110 0000 0000 0000 0000 0000

So first I take the exponent 10000001 that is 129-127=2 and 2
squared is 4.

The Mantissa? Well I guess it's (2**22)+(2**21) = 6291456. So now I
have:

1.6291456 * 4 = 6.5165824

But this number itself is stored as 40D0_87D8

Which works out to be 6.1110624


You can break down the mantissa like this:

1 (implied) + 0.5 + 0.25 = 1.75

1.75 x 4 = 7.00


.



Relevant Pages

  • Re: converting float to ascii w/o printf
    ... I would be really surprised if the internal format is not IEEE-754. ... some other floating point bit layout and interpretation than the messy ... for the exponent or even use some different base than 2 is the only ... It might even make sense to use a full 32 bit mantissa (depending on ...
    (comp.arch.embedded)
  • Re: 32 bit floating point
    ... PCs typically used IEEE 754 floating point, ... mantissa. ... positive, one if negative, 6 is the exponent, and 1.234 is the ... value it supports is positive zero (thought evidently you can have ...
    (comp.lang.apl)
  • Re: floating point representation
    ... instance the single precision has the low order 23 bits as a mantissa, ... the next 8 bits up are the exponent, and the H.O. bit is the sign bit. ... stored representation. ...
    (comp.lang.asm.x86)
  • Re: c interview questions wiki
    ... > "How will you obtain the mantissa of a floating point number?" ... The mantissa, on the other hand, might ... stripped of it's exponent, ... Life is a freak. ...
    (comp.lang.c)
  • Re: Fixed-point Math help
    ... and there are "gotchas" with using floating point that require care to use well. ... You can also examine the floating point formats ... but it is usually assumed for the mantissa at any convenient place and ... the exponent then adjusts this, left or right, for - or + values of the ...
    (comp.arch.embedded)