Author davidchambers
Recipients davidchambers
Date 2020-05-26.14:15:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590502519.54.0.593108276962.issue40780@roundup.psfhosted.org>
In-reply-to
Content
According to https://docs.python.org/3/library/string.html#format-specification-mini-language, “insignificant trailing zeros are removed from the significand” when 'g' is specified. I encountered a situation in which a trailing zero is not removed:

    $ python3
    Python 3.7.7 (default, Mar 10 2020, 15:43:03)
    [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> '{0:.3g}'.format(1504)
    '1.5e+03'
    >>> '{0:.3g}'.format(1505)
    '1.50e+03'
    >>> '{0:.3g}'.format(1506)
    '1.51e+03'

Is this behaviour intentional? If so, why is the trailing zero in 1.50 considered significant for 1505 but insignificant for 1504?
History
Date User Action Args
2020-05-26 14:15:19davidchamberssetrecipients: + davidchambers
2020-05-26 14:15:19davidchamberssetmessageid: <1590502519.54.0.593108276962.issue40780@roundup.psfhosted.org>
2020-05-26 14:15:19davidchamberslinkissue40780 messages
2020-05-26 14:15:18davidchamberscreate