Printing floating-point numbers with floating-point conversion specifiers : float Display « Data Type « C Tutorial






#include <stdio.h>

int main()
{ 
   printf( "%e\n", 1234567.89 );
   printf( "%e\n", +1234567.89 );
   printf( "%e\n", -1234567.89 );
   printf( "%E\n", 1234567.89 );
   printf( "%f\n", 1234567.89 );
   printf( "%g\n", 1234567.89 );
   printf( "%G\n", 1234567.89 );

   return 0;

}
1.234568e+06
1.234568e+06
-1.234568e+06
1.234568E+06
1234567.890000
1.23457e+06
1.23457E+06








2.20.float Display
2.20.1.Displaying Floating-Point Data Types with printf: %f
2.20.2.To create precision with floating-point numbers
2.20.3.%6f limits the output to only six digits
2.20.4.%e displays numbers in scientific format.
2.20.5.use the %E in printf() to display scientific-notation numbers
2.20.6.%g displays a floating-point number in either the %f or %e (scientific) format, depending on which is shorter.
2.20.7.Printing floating-point numbers with floating-point conversion specifiers