It is also possible to use the format() method to format numeric values. For floating point numbers a specifier can take the form:
% [alignment] [width] [.decimal] f
% indicates that the specifier (template) is starting, for each section
[alignment] not needed for right alignment. Include (-) for left alignment.
[width] is the number of characters to use for output
f indicates that the corresponding argument is a floating point number (or double)
For integer values a specifier can take the form:
% [alignment] [width] d
% indicates that the specifier (template) is starting, for each section
[alignment] not needed for right alignment. Include (-) for left alignment.
[width] is the number of characters to use for output
d indicates that the corresponding argument is an integer value
Be careful! "d" stands for "integer", not "double".
If numeric values exceed the formatting number of decimal digits, normal mathematical rounding will occur. |