Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 474
Lunar Mushrooms Avatar asked Dec 19 '11 08:12

Lunar Mushrooms


People also ask

Is 0.0 a floating-point number?

In addition, there is a floating-point zero; depending on the implementation, there may also be a ``minus zero. '' If there is no minus zero, then 0.0 and -0.0 are both interpreted as simply a floating-point zero.

What is the IEEE 754 single precision representation of 0?

0 represents a positive number while 1 represents a negative number.

How many bits is a floating-point number?

The most commonly used floating point standard is the IEEE standard. According to this standard, floating point numbers are represented with 32 bits (single precision) or 64 bits (double precision).

Can the mantissa be all zeros?

The values +infinity and -infinity are denoted with an exponent of all ones and a mantissa of all zeros. The sign bit distinguishes between negative infinity and positive infinity.


1 Answers

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.

like image 62
Sebastian Dressler Avatar answered Sep 24 '22 04:09

Sebastian Dressler