Floating Point Bug in Bob's Emulator

Ed G. edgee at cyberpass.net
Tue Apr 7 10:42:54 AEST 1998


I wrote a little square root program in "C" to test the floating
point in Bob Supnik's emulator (see attached code).  The program
works fine under Linux, but bombs on Bob's emulator, confirming
people's theory that the emulator has a floating point bug. 

I used Newton's method for the algorithm and only uses add,
subtract, multiply and divide.  The emulator produced identical
incorrect results for two different versions of the program one using
floats, the other doubles.

Here's what the program does on Bob Supnik's emulator:

# cc mysqrt.c
# a.out
Initial guess: 85070586659632214000000000000000000000.0000000000000000

guess: 1.0000000000000000
guess: 85070586659632214000000000000000000000.0000000000000000
guess: 1.0000000000000000
guess: 85070586659632214000000000000000000000.0000000000000000
guess: 1.0000000000000000
guess: 85070586659632214000000000000000000000.0000000000000000
guess: 1.0000000000000000

Here's what the program does on Linux:

[root at oskar uv7]# gcc mysqrt.c 
[root at oskar uv7]# a.out
Initial guess: 1.0000000000000000

guess: 1.5000000000000000
guess: 1.4166666666666667
guess: 1.4142156862745099
guess: 1.4142135623746899

My square root is: 1.4142135623746899

-------------- next part --------------
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  MYSQRT.C
     Date:  6 Apr 1998, 23:50
     Size:  413 bytes.
     Type:  Program-source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MYSQRT.C
Type: application/octet-stream
Size: 413 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/19980406/b6fc3e3f/attachment.obj>


More information about the TUHS mailing list