how has C bitten you?

Ken Turkowski ken at turtlevax.UUCP
Tue Aug 13 05:08:43 AEST 1985


In a previous article Brian Jones writes:
>>So, printf can never get a float as an argument, it always gets a double.
>>Therefore, %lf or %F are meaningless to printf.

PLEASE, don't use %F, when you can use %lf, and similarly for %E, %G,
%X, etc.

The biggest mistake in the implementation of printf is a disregard to
the standard in outputting hexadecimal and e-type output.  In the rest
of the programming world, hexadecimal is output as (for example):

	10AD            rather than             10ad

and floating-point e-type output as:

	3.1415926E+00   rather than             3.141592654e+00

Some implementations of printf intrepret %E and %G to mean "use 'E'
rather than 'e'".  Similarly, %X means "use the character set
[0123456789ABCDEF] rather than [0123456789abcdef] to print hexadecimal
numbers."  If you want to print out a long using cap hex, you would
use the format specifier "%lX".

Does anyone know what the proposed ANSI standard says about this?
-- 

Ken Turkowski @ CADLINC, Menlo Park, CA
UUCP: {amd,decwrl,hplabs,nsc,seismo,spar}!turtlevax!ken
ARPA: turtlevax!ken at DECWRL.ARPA



More information about the Comp.lang.c mailing list