Question about printf %g format
    Eric Norum 
    eric at ee.ualberta.ca
       
    Tue Jan  8 14:18:01 AEST 1991
    
    
  
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 at ee.ualberta.ca
University of Alberta
Edmonton, Canada.                   phone: (403) 492-4626
    
    
More information about the Comp.std.c
mailing list