Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - a datum of type "float" is an approximate representation of a real number. http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
A datum of type "float" is an approximate representation of a real number.
 Each datum of type "float" occupies 4 bytes.  If m is the magnitude of x
(an item of type "float") then x can be approximated if


      -126           128
     2      <= m <  2

or in more approximate terms if


     1.175494e-38 <= m <= 3.402823e38

Data of type "float" are represented internally as follows.  Note that bytes
are stored in memory with the least significant byte first and the most
significant byte last.


     +---+---------+---------------------+
     | S | Biased  |      Significand    |
     |   | Exponent|                     |
     +---+---------+---------------------+
      31    30-23           22-0

Notes
     

S
    S = Sign bit (0=positive, 1=negative)

Exponent
    The exponent bias is 127 (i.e., exponent value 1 represents 2**-126;
    exponent value 127 represents 2**0; exponent value 254 represents
    2**127; etc.).  The exponent field is 8 bits long.

Significand
    The leading bit of the significand is always 1, hence it is not stored
    in the significand field.  Thus the significand is always "normalized".
    The significand field is 23 bits long.

Zero
    A real zero quantity occurs when the sign bit, exponent, and significand
    are all zero.

Infinity
    When the exponent field is all 1 bits and the significand field is all
    zero bits then the quantity represents positive or negative infinity,
    depending on the sign bit.

Not Numbers
    When the exponent field is all 1 bits and the significand field is
    non-zero then the quantity is a special value called a NAN
    (Not-A-Number).

    When the exponent field is all 0 bits and the significand field is
    non-zero then the quantity is a special value called a "denormal" or
    nonnormal number.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson