-
Notifications
You must be signed in to change notification settings - Fork 280
Description
There are some slightly ambiguous rules in the string formatting docs around formatting decimal numbers. It would be helpful to clarify them a bit (or at least provide additional examples at the bottom):
Insignificant digits
When using a decimal clause and a double the rules state:
The value is formatted in base 10. No insignificant 0s must be included. If there are no significant digits after the . then it must be excluded.
Zeros after the decimal are typically considered significant (including trailing zeros), so what cases would result in the decimal point being excluded? I think that last sentence could be interpreted as removing any trailing zeros, but I'm not sure that's correct.
Rounding vs. Truncating
With formatting clauses that use precision, should the number be rounded or truncated? For example:
'%.3f'.format(3.14159)'
Is the resulting string equal to 3.141 or 3.142?