Floating point puzzle

Alan J Rosenthal flaps at dgp.toronto.edu
Thu Aug 11 22:06:25 AEST 1988


In article <259 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>TRAP:  floating-point constants such as 1.0 are DOUBLE precision, so if the
>compiler sees float x; ... x+1.0, it will do the addition in double
>precision.  In such a case, I do	float one = 1.0; ... x+one...

AACKK.. Pascal programmer detected.  Use a cast.  "x + (float)1.0" is the
same as "x + one" in your example.  At least, it should be.

--
owotd (rot13): fabgentf




More information about the Comp.lang.c mailing list