incorrect floating point precision

From: Harrison, Robert J <Robert.Harrison_at_pnl.gov>
Date: Tue, 17 Jul 2001 11:56:10 -0700

In trying to resolve my floating point problems I ran
the linpack 100x100 benchmark since it is a nice
self contained test of both speed and precision.
It reports that the DOUBLE PRECISION (64-bit)
arithmetic is only accurate to single precision.
This is true for both libm-2.2.2 and 2.2.3, though
they did give different numbers.

A representative problem is that 4.0d0/3.0d0 is accurate
to only
  - 7 figures if the compiler evaluates the expression
  - 10 significant figures if it is evaluated at runtime.
To convince you that this is not just a Fortran problem
I give a sample C code and output below.
I tried both gcc-2.95 and 3.0.

Does anyone know about the status of 64-bit
floating point emulation?

It's also fairly important to have consistency between compiler
and runtime evaluated values. Is this an issue
that the gcc folks are already aware of, or should
I copy them on this message?

Thanks,

 Robert

/home/rjh# cat test.c
#include <stdio.h>
 
int main()
{
  double a=4.0, b=3.0;
  printf("a=%22.17f b=%22.17f\n",a,b);
  printf("a/b=%22.17f\n", a/b);
  printf("4.0/3.0=%22.17f\n", 4.0/3.0);
  return 0;
}
/home/rjh# gcc test.c
/home/rjh# ./a.out
a= 4.00000000000000000 b= 3.00000000000000000
a/b= 1.33333333302289248
4.0/3.0= 1.33333301544674043
/home/rjh# uname -a
Linux intimate 2.4.3-rmk2-np1 #2 Mon May 14 12:21:48 PDT 2001 armv4l unknown
/home/rjh# ls -l /lib/libm.so.6
lrwxrwxrwx 1 root root 13 Jan 23 04:34 /lib/libm.so.6 ->
libm-2.2.3.so
/home/rjh# gcc -v
Reading specs from /usr/lib/gcc-lib/arm-linux/2.95.4/specs
gcc version 2.95.4 20010703 (Debian prerelease)
/home/rjh#
Received on Tue Jul 17 2001 - 11:50:27 EDT

This archive was generated by hypermail 2.2.0 : Mon Jul 25 2005 - 17:21:11 EDT