Subject: standards/5150: 1.3 i386 fails "paranoia" IEEE 754 math tests
To: None <>
From: Charlie Root <>
List: netbsd-bugs
Date: 03/11/1998 08:19:08
>Number:         5150
>Category:       standards
>Synopsis:       1.3 i386 fails "paranoia" IEEE 754 math tests
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 11 07:20:00 1998
>Originator:     Tim Rightnour
Tim Rightnour    -
>Release:        1.3<NetBSD-current source date>
System: NetBSD polaris 1.3 NetBSD 1.3 (POLARIS) #5: Fri Mar 6 05:30:19 MST 1998 root@polaris:/usr/src/sys/arch/i386/compile/POLARIS i386


(this may not be properly categorized.. It may fall under the libm, or 
port-i386.  It could also be a bug with gcc)

running the math test "paranoia" on an i386 gives strange results.

final outputs for various compilations given:

compiling with gcc -o paranoia paranoia.c -lm
No failures, defects nor flaws have been discovered.
Rounding appears to conform to the proposed IEEE standard P754,
except for possibly Double Rounding during Gradual Underflow.
The arithmetic diagnosed appears to be Excellent!

compiling with gcc -O2 -o paranoia paranoia.c -lm
Seeking Underflow thresholds UfThold and E0.
DEFECT:  Difference underflows at a higher threshold than products.
Smallest strictly positive number found is E0 = 0 .

Trying it on Y = -Inf .
finds a FLAW:  -(-Y) differs from Y.

FAILURE:  Comparisons involving +--Inf, +-Inf
and +-4.94066e-324 are confused by Overflow.

DEFECT:  Badly unbalanced range; UfThold * V = -Inf
        is too far from 1.

SERIOUS DEFECT:    X / X differs from 1 when X = -Inf
  instead, X / X - 1/2 - 1/2 = NaN .

The number of  FAILUREs  encountered =       1.
The number of  SERIOUS DEFECTs  discovered = 1.
The number of  DEFECTs  discovered =         2.
The number of  FLAWs  discovered =           1.

The arithmetic diagnosed has unacceptable Serious Defects.
Potentially fatal FAILURE may have spoiled this program's subsequent 

compiling with gcc -O2 -m486 -o paranoia paranoia.c
gives the same results as the O2 test.

note, that the sparc machine sitting next to me also running 1.3 passes 
all the tests with flying colors.  This may indeed be a flaw in the i386 
chip's floating point unit.  I have no idea.  (my sparc works fine in 
both regular and -O2)

The -O2 results seem to indicate some sort of bug in the i386 
optimization routines. Especially in the -(-Y) part.  I'm not completely 
sure what caused the double rounding warning in the first run.

I'm not really a mathematician, and I don't actually need this to work.. 
but if other people are trying to use an i386 for some sort of 
calculation.. this might be a problem for them. I just saw this test, and 
was bored and decided to try it out.. ;)

I've tested this on an Intel Pentium, a Cyrix 486DLC-50,  and my Intel 
486-33 with the same results.

My Sparc 1 (4/60) passed all with no problems whatsoever.


download paranoia.c from , compile as 
above and run.

on my i386 it fails.. works ok on my sparc 1.  I have no access to other 
platforms to test this on.


I have no idea.. sorry. I'm not good enough with that sort of math to 
even attempt it.