This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients John Belmonte, eric.smith, mark.dickinson, serhiy.storchaka, steven.daprano
Date 2021-12-07.09:54:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638870882.74.0.271280110061.issue45995@roundup.psfhosted.org>
In-reply-to
Content
Well, it makes sense for negative zero produced by rounding.

But if we add a special support for this case, it would be useful to have some control on the type of rounding. Currently floats are rounded to the nearest decimal number, but in some cases it would be better to round up, down, toward zero or infinity (seed for example issue44884).

You can round explicitly before formatting, but this solution is also applicable for this issue:

>>> '%5.1f' % (round(-.00001, 1) + 0.0)
'  0.0'
History
Date User Action Args
2021-12-07 09:54:42serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson, eric.smith, steven.daprano, John Belmonte
2021-12-07 09:54:42serhiy.storchakasetmessageid: <1638870882.74.0.271280110061.issue45995@roundup.psfhosted.org>
2021-12-07 09:54:42serhiy.storchakalinkissue45995 messages
2021-12-07 09:54:42serhiy.storchakacreate