what is meaning of %g in c
what is meaning of %g in c
EmbLogic Embedded Technologies Pvt. Ltd.
E 16, Ground Floor, Sector 3, Noida - 201301, India
Phone: +91 120 6486139, +91 120 6486140, 9560872999
Email: info@emblogic.org
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.

%g is like %f,%g use at the place of %f and cheak it
%g is not like as %f it has the large difference when you use padding.
eg.
when you use printf(” %3g “, 10/3); it gives output 3.33
here the significant digit( mentioned by padding ) are counted form the right most side of digit.
but in case of %f
eg ..
printf(” %3f “, 10/3); it gives output
3.333333
^^^
note the differece the digit before decimal is placed with in 3 character space. but when result need more compartment of spaces then it does not affect the result.
e.g..
printf(” %3f “, 10000/3); it gives output 3333.333333