Lunar Mushrooms
Lunar Mushrooms

Reputation: 8948

If all bits are 0, what is the value of IEEE floating point?

If all bits are 0 (example I memset the floating point variable to all 0), what is the value of IEEE floating point used in gcc? It is guaranteed to be 0.0 ?

I guess for other floating point formats result may vary. But my question is specific to IEEE floating point used with gcc.

Upvotes: 40

Views: 21015

Answers (1)

Sebastian
Sebastian

Reputation: 8164

If the implementation is IEEE 754 compliant there exist special cases for different bit-combinations, like documented here.

For your case: When all bits (sign, exponent, mantissa) are zero the floating point value represents also zero, as defined by IEEE 754. More specifically, that value is a "positive zero", also written as +0.

Upvotes: 52

Related Questions