From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076335021347.tru64-unix-managers.marc@archive.invalid> From: chu () musp0 ! Jpl ! Nasa ! Gov (Eugene Chu) Date: Wed, 10 Jul 1996 09:02:57 +0000 To: tru64-unix-managers Subject: Floating point problem revisited X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076335021347 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 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