ANSI, =, hash, Integer, Float

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Dec 17 03:12:11 UTC 2002


Colin Putney <cputney at whistler.com> wrote:
	Here's another proposal: make Float>>= call #shouldNotImplement.
	
	I wonder what, if anything, it would break?
	
Well, for one thing, it would leave 0 = 0.0 true,
and ANSI requires that (x = y) implies (y = x).

Equality is perfectly well defined for IEEE floating point arithmetic.
Unlike C, Smalltalk specifies the grouping of message sends, so if you
have a Smalltalk layered atop an IEEE arithmetic, there is no question
about when two Floats should be equal and when they should not.

It isn't equality between floating point numbers that's the problem.
It's equality between floating point numbers and rational numbers.
Prolog solved the problem by recognising that
    "X is the same key as Y" (=)
and "X and Y are pretty much the same number" (=:=)
are different relations, so that 0 = 0, 0.0 = 0.0, -0.0 = -0.0
are all true, 0 = 0.0, 0.0 = -0.0, -0.0 = 0 are all false,
and 0 =:= 0.0, 0.0 =:= -0.0, -0.0 =:= 0 are all true.




More information about the Squeak-dev mailing list