log10(8)

Karl Heuer karl at haddock.ima.isc.com
Tue Feb 27 07:29:32 AEST 1990


In article <90057.130433CMH117 at psuvm.psu.edu> CMH117 at psuvm.psu.edu (Charles Hannum) writes:
>You may also have to change the printf() to:
>   printf("%lf", l);

No.  "%f" is the correct printf format for double; "%lf" is undefined.
Backward compatibility strikes again.

(In an ideal world, the three floating-point sizes would be called "short
float", "float", and "long float", and their printf/scanf formats would be
"%hf", "%f", and "%lf".  Unfortunately, for historical reasons the types are
"float", "double", and "long double", their scanf formats are "%f", "%lf", and
"%Lf", and their printf formats are <none>, "%f", and "%Lf".  There is no
printf format for float, since one cannot directly pass floats by value to a
variadic function.)

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list