The f
specification is for floating-point numbers.
Note that x
s are included in the printf
statement to clarify
the placement of padding characters.
Display float or double:
printf ("x --- Result --- x 3.141590 x x -3.141590 x
Display with two digits following the decimal point:
printf ("x --- Result --- x 3.14 x x -3.14 x
Display with spaces, if necessary, to fill a six-character field:
printf ("x --- Result --- x 3.14 x x -3.14 x
Display with spaces, if necessary, to fill a six-character field; if more than six characters are involved, display them all anyway:
printf ("x --- Result --- x 3.141590 x x -3.141590 x
Display with spaces, on the right, if necessary:
printf ("x --- Result --- x 3.14 x x -3.14 x
Always include sign:
printf ("x --- Result --- x +3.14 x x -3.14 x
Always include sign and pad on the right:
printf ("x --- Result --- x +3.14 x x -3.14 x