4.?bsd printf("%g") incorrectly documented (with fix)

Arthur David Olson ado at elsie.UUCP
Wed Dec 4 01:24:45 AEST 1985


Index:		man/man3/printf.3s Fix

Description:
	According to the manual page, if printf's "g" format is used,
	"The float or double arg is printed in style d, in style f, or in
	style e, whichever gives full precision in minimum space."
	This is not always true.

Repeat-By:
	Giving these commands to the shell:
		echo 'main() { printf("%.0g\n", 0.0006); }' > try.c
		cc try.c
		a.out
	and noting that the output is
		0.0006
	rather than the shorter
		6e-04

Fix:
	Since the actual behavior of printf seems to be what may
	eventually become standard, the fix in this case is to change the
	writeup.

	Make this change to "man/man3/printf.3s", where the text to be
	replaced appears between ".ig" and ".." directives, and the text
	to be added appears between ".NU" and ".." directives.  As usual,
	the trade secret status of the material involved precludes a
	clearer posting.

	.ig
	.BR e ,
	whichever gives full precision in minimum space.
	..
	.. New stuff follows
	.BR e .
	The style used depends on the value converted; style
	.B e
	will be used only if the exponent resulting from the conversion is less
	than
	.B \-4
	or greater than the precision.
	..
--
Bugs is a Warner Brothers trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado at seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Comp.bugs.4bsd.ucb-fixes mailing list