Thursday, July 30, 2009

What is the use of %g in C programming?

c programming %G format specifier

What is the use of %g in C programming?
That prints a floating point number. If the number has an exponent less than -4 it's in exponent notation, otherwise it is in fixed point notation.





For example:


printf("%g\n",0.00004"); is 4e-05, but:


printf("%g\n",0.0004"); is 0.0004





For input, it's the same as %e (input using exponent notation).


No comments:

Post a Comment