Topic: That old double d [was And you thought that the Pentium bug was bad!]
Author: hogan@slinky.cs.nyu.edu (Hogan Long)
Date: 1995/06/22 Raw View
luehrs@sokrates.informatik.uni-Bremen.de (Carsten Luehrs) writes:
> JdeBP@jba.co.uk (Jonathan de Boyne Pollard) writes:
>|> Ronald F. Guilmette (rfg@rahul.net) wrote:
>|> : double d = 0.9;
>|> : int main ()
>|> : { double d = 0.8;
>|> : { extern double d;
>|> : printf ("%f\n", d);
>|> : }
>|> : }
>|> : This program *should* print 0.900000, and with most compilers, it does.
>|> So just for the record, some more interesting results.
>|> Borland C++ 2.0 for OS/2 : 0.900000
>|> IBM VisualAge C++ 3.00 for OS/2 : 0.900000
>|> MetaWare High C++ 3.31a for OS/2 : 0.900000
>|> Watcom C++ 10.0b on OS/2 : 0.800000
>|> EMX C++ 0.9a on OS/2 : 0.900000
>Even better gcc 2.6.3 on Solaris 2.3 give 0.8 - g++ 2.6.3 gives 0.9 :-)
Wait just a sec.... isn't this one of those things
that changed with the new C++ naming standards?
My guess (and I may be wrong - you have to
check with someone more guruish than I am)
is that in C this should be 0.800000 and in
C++ 0.900000
It may also be that the behavior for this
construct is not defined in ANSI C but, as
we all know with the new C++ naming rules in
C++ it is clearly defined that 0.900000 should
be output. If the behavior is not defined in
C then all C compilers will be correct! :)
If I am right than gcc and g++ work just fine,
but someone should file a bug report to Watcom.
Hogan
PS - Is guruish a word? If not it should be. ;)