tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: chu () musp0 ! Jpl ! Nasa ! Gov (Eugene Chu)
To: tru64-unix-managers
Subject: Floating point problem revisited
Date: Wed, 10 Jul 1996 09:02:57 +0000	[thread overview]
Message-ID: <96076335021347.tru64-unix-managers.marc@archive.invalid> (raw)

Ages ago, someone either on this list or one of the DEC news groups
mentioned this problem, and I don't remember how it was resolved.
I've run into again on my AlphaStation 250 4/266 running OSF v3.2c.
Basically, it has to do with how a particular expression is displayed
by the printf function in their C program:

#include <stdio.h>

main()

{
float  fff = 4.333;
float  ggg = 1/65535;

printf("ggg = %f\n",ggg);
printf("1/65535 = %f\n",1/65535);
printf("fff = %f\n",fff);
printf("1/65535 = %f\n",1/65535);
printf("ggg = %f\n",ggg);

}

gives the outputs:

ggg = 0.000000
1/65535 = 0.000000
fff = 4.333000
1/65535 = 4.333000
ggg = 0.000000

while on all other systems I've tested it on (Solaris, Ultrix, IRIX, AIX)
gives the correct result:

ggg = 0.000000
1/65535 = 0.000000
fff = 4.333000
1/65535 = 0.000000
ggg = 0.000000

On the OSF system, DEC C v3.5 was used, but he same outputs are
generated on a system running OSF v1.3a and DEC C v1.0(?); the second
output for 1/65535 picked up the value of fff from the previous line for
some reason.  This didn't seem to change regardless of the optimization
flags used.

In playing with this program a little, I found that if the expression
1/65536 was ever assigned to a variable, the correct results will be
obtained, and this anomaly appears to only show up on the printf.  But
it's still an anomaly, and certainly not befitting an otherwise
excellent compiler that is known for its strict adherance to standards.

So, does anyone know if DEC has a fix for this?

eyc

                 reply	other threads:[~1996-07-10  9:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox