问题
the question is as follows :
Write down all the real numbers that have more than 1 representation in IEEE-754 of single precision.
Now, considering +0 and -0 are different, are there any numbers that have this property?
回答1:
There are none.
The IEEE754 representation is canonical, which means that all numbers have precisely one representation if any, and no others.
Format of an IEEE754 single-precision floating-point number
31 0
seeeeeeeemmmmmmmmmmmmmmmmmmmmmmm
Mapping to
(-1)^s * 2^(eeeeeeee - 127) * 1.mmmmmmmmmmmmmmmmmmmmmmm (binary)
Proof of uniqueness of representation
- The sign is encoded in the sign bit,
s
. Two putatively different representations of the same real number must have the same value ofs
, because only that field controls the sign. - The location of the most-significant
1
-bit, in digit positions left from the decimal comma, is encoded in biased format in the eighteeeeeeee
exponent bits. Two putatively different representations of the same real number must have the same value ofeeeeeeee
, because only that field controls the position of the most significant 1-bit. - The 23 bits immediately below the most-significant
1
-bit are encoded in the mantissa (mmmm...
). Two putatively different representations of the same real number would have to have the same mantissa value, because only that field controls the 23 bits immediately below the most-significant1
-bit of the real number.
The conclusion is a contradiction. Two putatively different representations of a same real number would have to have the same sign, exponent and mantissa; In other words they must be identical.
This discussion ignores all the special values, like infinities, NaNs and denormals.
来源:https://stackoverflow.com/questions/17251767/all-real-numbers-that-have-more-than-1-representation-in-ieee-754-of-single-prec