Bug?

Norman Diamond diamond at csl.sony.co.jp
Wed Oct 4 14:15:24 AEST 1989


In article <9986 at alice.UUCP> ark at alice.UUCP (Andrew Koenig) writes:

>Even if the == operator includes a fuzz factor, it's hard to imagine
>a sensible implementation in which (a-b)==0 is true unless a and b
>are truly identical.

Sorry Mr. Koenig, it's easy to imagine.  Every hardware floating-point
system and most software ones have situations where (a-b)==0 but a != b.

For example (which obviously generalizes), imagine a base-10 system
where exponents can range from -99 to +99.  Let:
  a == 0.100001e-99
  b == 0.100002e-99
Then obviously a != b.  But what happens when (a-b) is computed?
(a-b) --> (-0.000001e-99) --> (-0.100000e-104) --> (0.000000e-99).

-- 
Norman Diamond, Sony Corp. (diamond%ws.sony.junet at uunet.uu.net seems to work)
  The above opinions are inherited by your machine's init process (pid 1),
  after being disowned and orphaned.  However, if you see this at Waterloo or
  Anterior, then their administrators must have approved of these opinions.



More information about the Comp.lang.c mailing list