printf() float format error

haggas at kean.mun.ca haggas at kean.mun.ca
Tue Nov 21 02:26:48 AEST 1989


The expression:
printf("%03.0f", num);
where num is a floating point number of three digits or less, eg 007
will not pad with zeros a right justified number of less than 3 digits,
with Microsoft Optimizing Compiler V5.1.  This expression will, however,
work on a VAX 1187 using the UNIX "C" compiler.
Padded zeros will be inserted if the number is an integer with the 5.1
compiler.
The microcomputer is a NEC PowerMate '386, equiped with a 80287 co-
processor.
The Microsoft manual states in the printf() library reference that if the
width argument is prefixed with a zero, the output, that is less than the
specified with, will be padded zeroes. 
Has anyone experienced this problem and resolved it?



More information about the Comp.lang.c mailing list