[docs] [issue34273] %f is confusingly associated with fixed point format

Mark Dickinson report at bugs.python.org
Mon Jul 30 10:52:32 EDT 2018

Mark Dickinson <dickinsm at gmail.com> added the comment:

FTR, here "fixed point" refers to the output representation (a decimal string) rather than the input (a floating-point binary value). The output of %f gives a *fixed* number of places after the decimal point (6 by default).

Contrast with %e, which gives a floating-point output representation.

But yes, there are probably less confusing ways to word this. Did you have a particular alternative wording in mind?

Here's the behaviour of %f for different scale values: note that the output always has the same number of digits after the point, but the number of significant digits varies.

>>> "%f" % math.pi
>>> "%f" % (100.0 * math.pi)
>>> "%f" % (0.01 * math.pi)

And here's %e. Now it's the other way around: the number of significant digits stays the same, but the exponent changes to reflect the magnitude.

>>> "%e" % math.pi
>>> "%e" % (100 * math.pi)
>>> "%e" % (0.01 * math.pi)

nosy: +mark.dickinson

Python tracker <report at bugs.python.org>

More information about the docs mailing list