Fun_People Archive
3 Dec
A crazed gunmen is loose, THREE students are dead...


Date: Sat,  3 Dec 94 12:44:41 PST
To: Fun_People
Subject: A crazed gunmen is loose, THREE students are dead...

Forwarded-by: bostic@CS.Berkeley.EDU (Keith Bostic)
Forwarded-by: Wendell Craig Baker <wbaker@splat.baker.com>
From: pratt@Sunburn.Stanford.EDU (Vaughan R. Pratt) 
1 Dec 1994 08:53:56 GMT Computer Science Department, Stanford University. 

One-liner with incorrect integer quotient

It's easy to get an incorrect integer answer on the Pentium if one
resorts to subtraction.  However this tends to mask the seriousness of
the error since subtraction can greatly magnify small relative errors.
Here's a one-liner that is squeaky clean in that regard: it uses
nothing but a single division.

main(){double x=137489121280.0, y=3145727.0; printf("%.0f\n", x/y);}

This prints 43704 when other machines deliver 43707.

Observation: integers have a certain immediacy somehow lacking in
reals.  Imagine you are one of the 43707 students at Giant State U.,
and a crazed gunman shoots three of your fellow students and then
escapes a police cordon.  Do you regard this decrease in the student
population as insignificant, or do you stay at home the next day?

Question: what is the least quotient of two integers which when rounded
to the nearest integer (the effect of formatting with "%.0f") is off by
at least 2 on the Pentium?  (The bug is not very convincing when only
off by 1:  you might have obtained 123.499999 when the right answer is
123.5000001, which rounding makes respectively 123 and 124.)  In
particular is there a four digit such quotient?  Such a quotient would
mean that the bug is even worse than anyone imagined.

My own concern with these errors has to do with my work on curve
fitting in digital typography, which for reasons discussed near the
bottom of column 1 of page 149 of my SIGRAPH'87 article is unstable at
single precision but nicely robust at double precision.  I am currently
using Suns plus one very newly acquired Pentium (with the bug,
unfortunately) for this work.

I should mention in this context that I hold Sun stock.



[=] © 1994 Peter Langston []