Re: 0.99999998 (was: Unknown SQL)

From: Bob Badour <bbadour_at_golden.net>
Date: Sat, 21 Jul 2001 23:29:28 GMT
Message-ID: <U3vS6.817$5f4.201119800_at_radon.golden.net>


>>>IEEE gets more complicated than that! In IEEE arithmetic, -0 and +0
>>>are distinct values. So 1/-0 == -INF, 1/+0 == +INF. And yet -0 == +0
>>>in all tests.
>>>
>>>I doubt many people will have problems with this particular thing in
>>>conversion, but there is a more general point, that is that equality
>>>is not as simple a test as it may first seem.
>>
>>The fact of the matter is: -0 does equal +0. I don't see what the problem
>>is.
>>
>
>Now we digress!
>
>Let x := -0. Let y := +0. Assume IEEE arithmetic. The following are
>true.
>
>a) x and y are stored differently.

Which is my original point: The value does not change even when the representation does.

>b) If you test x == y, you get true.

Which is correct.

>c) If you test 1/x == 1/y, you get false.

Actually, you should get a divide by zero error. Both sides of the comparison are undefined.

>The following is not true in IEEE, but could have been without
>inconsistency, and emphasises the point.
>
>d) log(x) == NaN; log(y) == -INF.

Emphasizes what point? That IEEE has inconsistencies? Again, both of these comparisons should result in a range error since at least one side of the comparison is undefined.

>So in some cases it looks as though x "equals" y, and in others x
>"doesn't equal" y !

This is a consequence of trying to interpret undefined values.

>Although x == y, we need to be careful to preserve the stored value
>(and the sign) when copying them between platforms.

Actually, we do not -- the sign does not change the value. We only need to correctly handle undefined values on both platforms. Received on Sun Jul 22 2001 - 01:29:28 CEST

Original text of this message