Re: 0.99999998 (was: Unknown SQL)

From: Sam Staton <sam.staton_at_bigfoot.com>
Date: Sat, 21 Jul 2001 23:29:24 GMT
Message-ID: <kqqkht4i27n66t71tvcr03an4ei1dpu1a2_at_4ax.com>


On Sun, 3 Jun 2001 12:09:22 -0400, "Bob Badour" <bbadour_at_golden.net> wrote:

>>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.

  1. x and y are stored differently.
  2. If you test x == y, you get true.
  3. If you test 1/x == 1/y, you get false.

The following is not true in IEEE, but could have been without inconsistency, and emphasises the point.

d) log(x) == NaN; log(y) == -INF.

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

Although x == y, we need to be careful to preserve the stored value (and the sign) when copying them between platforms. Received on Sun Jul 22 2001 - 01:29:24 CEST

Original text of this message