Rohan Nanda
Rohan Nanda

Reputation: 13

How computer stores 0.000000f according to IEEE 754 floating point representation?

As we know that we can represent any floating number in IEEE 754 floating point representation.But, in all the floating number we get something like 1.(some mantissa) * 2^(some exponent) where 1 is always fixed at first position and thus we assume it while converting back any IEEE 754 floating point number to decimal number.But what will we assume in case of 0.000000f as in that case we can not represent the number in 1.(some mantissa) * 2^(some Exponent) as it can never have 1 in starting of mantissa except 0.

Upvotes: 1

Views: 170

Answers (3)

chux
chux

Reputation: 153456

How computer stores 0.000000f according to IEEE 754 floating point representation?

When a float is smaller than the smallest normal non-zero FLT_MIN (0 00000001 00000000000000000000000), it is stored with a encoded biased exponent of 0 (s 00000000 xxxxxxxxxxxxxxxxxxxxxxx). The implied bit is no longer 1, but 0 and the effective biased exponent is 1.

When xxxxxxxxxxxxxxxxxxxxxxx is all zeros, the value is a +0.0f or -0.0f.


A float with the encoded biased exponent of 0 and xxxxxxxxxxxxxxxxxxxxxxx not zero, it is a sub-normal.

FLT_TRUE_MIN is 0 00000000 00000000000000000000001, the smallest positive non-zero value.

Upvotes: 4

Sneftel
Sneftel

Reputation: 41474

As Alias answered, "all exponent and significand bits set to zero" is defined as a zero. It's also possible to see zero as a special case of denormal number. When all exponent bits are set to zero (the smallest possible exponent), there is no leading 1 assumed for the mantissa, so if the significand is also zero then the resultant value (interpreted as a denormal number) is zero.

Upvotes: 2

alias
alias

Reputation: 30428

The all 0's pattern is reserved for 0:

              3  2          1         0
              1 09876543 21098765432109876543210
              S ---E8--- ----------F23----------
      Binary: 0 00000000 00000000000000000000000
         Hex: 0000 0000
   Precision: SP
        Sign: Positive
    Exponent: -127 (Stored: 0, Bias: 127)
   Hex-float: 0x0p+0
       Value: +0.0

Note that there are two 0's in the IEEE representation: +0, and -0; which can be distinguished. The pattern 0x80000000 is used for the latter:

              3  2          1         0
              1 09876543 21098765432109876543210
              S ---E8--- ----------F23----------
      Binary: 1 00000000 00000000000000000000000
         Hex: 8000 0000
   Precision: SP
        Sign: Negative
    Exponent: -127 (Stored: 0, Bias: 127)
   Hex-float: -0x0p+0
       Value: -0.0

Upvotes: 3

Related Questions