printf zero-pads strings?

Chris Torek chris at mimsy.umd.edu
Fri Oct 27 14:32:19 AEST 1989


>In article <20371 at mimsy.umd.edu>, chris at mimsy.umd.edu (Chris Torek) writes:
>	if a precision is specified, the |0| flag will be ignored.
>	(quoted from the standard)

In article <1470 at crdos1.crd.ge.COM> davidsen at crdos1.crd.ge.COM
(Wm E Davidsen Jr) writes:
>  This certainly doesn't grab me as being 'least astonishment.' I
>interpret this to mean that if I say %010.2f the |0| is ignored. Yes?

No; that clause applies only to [diouxX] formats.  Thus, the 0 is not
ignored for `%010.2f', but it is ignored for `%010.2d'.

Apparently the logic is that the precision here says exactly how many
numeric digits are to appear, hence the precision says how many leading
zeros there can be, and so the 0 flag should be ignored.

>... I certainly find it easier to explain when leading zero means pa
> with zeros. Period.

I happen to agree, but my copy of the draft does not.

Chris
-- 
`They were supposed to be green.'
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.std.c mailing list