Shouldn't 2 hash = 2.0 hash? [LONG]
Jan Theodore Galkowski
algebraist at salonmember.com
Thu Dec 2 19:26:10 UTC 1999
On Wed, 1 Dec 1999 19:21:54 David N. Smith (IBM) wrote:
>At 18:28 -0500 12/1/99, David N. Smith \(IBM\) wrote:
>>...SNIP...
>>Also note that if not, one could have the case where:
>>
>> 1.0 = 1.0 => false
>>
>>but
>>
>> 1.0 == 1.0 => true!
>
>There is another case that follows.
>
>If, for equal a and b, if a=b is false, a>=b would *also have* to
>answer false, else we could write an equality test this way:
>
> (a<b
> ifFalse: [a>=b & (a>b) not]
> ifTrue: [a<=b & (a<b) not])
>
>But, if a=b answers false, and a>=b answers false, and obviously a<b
>and a<=b are false, how do the values compare? In IEEE there is one
>other option, called unordered, but that happens only when one or
>both values are NaNs, and both a and b would fail the test for NaNs.
>
>So, making a=b answer false leads to a logical impossibility where
>all possible relationships are false.
Well, Dave, yes, it would. The definition
of "=" as always false simply means that
the object's essence is on some other
dimension of comparability, and "=" can't
hack it, as if, for instance, one were
trying to compare two complex numbers with
a scalar operation. To be consistent with
what's intended, I probably should have said
instead that "=" sent to flonums yield
doesNotUnderstand.
The other alternative, I guess, is to
insist that flonums aren't totally ordered.
Perhaps, however, I'm still thinking too
much in terms of other languages. Eiffel
has a type structure, a notion of
conformability, and multiple inheritance to
help sort things out. Notably, comparability
is defined in a separate class COMPARABLE
from the class NUMERIC, and COMPARABLE
does not define an "=". It does define "<"
and ">" as well as their inclusive counterparts,
eg, "<=". And COMPARABLE descends from
PART_COMPARABLE which is used for things
which have but partial orderings. To do
anything, one inherits from NUMERIC and from
COMPARABLE. And one could, then, use
"a = b" as a macro notation for
(a <= b) & (b <= a)
Where the equality test comes up in DuBois'
book ("Object Technology for Scientific
Computing"), he passes a function as a parameter
which yields true for the termination case,
and thus -- perhaps wisely -- passes the buck.
OTOH, in the original MATLAB, that quintessential numerical interpreter for modern
flonum-hungry calculations, had no types or classes, and no inheritance. Yet "=" was
defined in terms of a system global, eps,
and, for reals, "a = b" always means
abs( a - b ) < eps
[snip]
--Jan Galkowski
---
___________________________________________
demiourgos at smalltalk.org squeak.org/
home.stny.rr.com/algebraist/
www.smalltalk.org/ jtgalkowski at alum.mit.edu
Get your FREE, private e-mail account at http://www.salonmember.com.
More information about the Squeak-dev
mailing list
|