[comp.std.c] Question about printf %g format

eric@ee.ualberta.ca (Eric Norum) (01/08/91)

I have a question about printf's `%g' format.  Specifically, what should

	#include <stdio.h>
	main ()
	{
		printf ("%.3g\n", 0.0001234);
	}

print?

It seems to me that leading zero's shouldn't count as significant when
printf chooses to use `f' format ..... so `0.000123' should be printed.

The HP-UX and Sun 4.1  machines here agree with me, but some other
systems choose to print `0'. (!!!)

I hope the latter behaviour is wrong, but when I read K&R II page 244 I'm
not sure.  Is the `correct' behaviour documented somewhere?

-- 
Eric Norum
Dept. of Electrical Engineering      eric@ee.ualberta.ca
University of Alberta
Edmonton, Canada.                   phone: (403) 492-4626