[squeak-dev] a==b "true" but a=b "false"
Eliot Miranda
eliot.miranda at gmail.com
Thu Sep 4 19:33:54 UTC 2014
On Wed, Sep 3, 2014 at 4:11 PM, Chris Muller <ma.chris.m at gmail.com> wrote:
> When could it happen?
>
> A: With Float nan.
>
> Float nan == Float nan "true"
>
> Float nan = Float nan "false"
>
> It violates what I have long considered an invariant that if a==b, then
> a=b.
>
> Real world context: When two DB clients change the same object in the
> exact same way, it's not a conflict. If they change it differently,
> it is.
>
> They've both made the same reference to Float nan, but just asking if
> they made equivalent changes still reports false. So I have to put in
> a complicated special check for NaN first..??
>
> Okay, I actually wrote: (a==b or: [a=b]) but who would ever write
> that or not "simplify it" in teh future if they saw it?
>
> Comments? Why shouldn't Float nan = Float nan?
>
Because non-a-numbers result from overflowing or underflowing computations,
and hence, just because two computations produce the same not-a-number
doesn't imply that the two computations are equivalent. This is why
the IEEE-754
standard requires that NaN != NaN.
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140904/6ec34a6a/attachment.htm
More information about the Squeak-dev
mailing list
|