About Float negativeZero

nicolas cellier ncellier at ifrance.com
Sat Nov 24 01:13:51 UTC 2007

Meaning of Float negativeZero is to represent a negative number so small 
that we cannot represent it with smallest available Float...
That occurs after an underflow.
Like for example
	-1.0e-300 * 1.0e-100

We know it is negative, but in the same time, we cannot distinguish it 
from zero...
IEEE 754 decided that
	(Float negativeZero = 0.0) = true

Rationale: there is no positiveZero, so there is no reason why
	(-1.0e-300 * 1.0e-100 = 0.0) = false
	(1.0e-300 * 1.0e-100 = 0.0) = true

A consequence of this in Squeak is:
	Float negativeZero negative = false
As the name does not tell...

Tricky Float...
I will try to play with this logic:

One feature in IEEE is division by a negativeZero:
	(1.0 / Float negativeZero)
is expected to produce a negative infinity.

So I expect a breach of logic with:
	(1.0 / Float negativeZero) negative = true
Not in Squeak, we are saved by a ZeroDivide...

Sure I can make it with FloatArray:
	(1.0 / (FloatArray with: Float negativeZero)) first negative = true

But there
- I find a bug (http://bugs.squeak.org/view.php?id=6782)
- after correcting, still have a ZeroDivide.

Do I lack the plugin?

More information about the Squeak-dev mailing list