[issue45995] string formatting: normalize negative zero

John Belmonte report at bugs.python.org
Tue Dec 7 07:22:14 EST 2021


John Belmonte <john at neggie.net> added the comment:

> changing %-formatting doesn't seem viable

I'm concerned about treating %-formatting specially.  As far as float/complex, the logical and efficient place to put this change seems to be PyOS_double_to_string(), which affects all three formatting options.

For example, the dtoa case is as simple as this change to format_float_short():

    /* coerce negative zero to positive */
    if (sign == 1 && ((digits_len == 0 && decpt == -1) ||
                      (digits_len == 1 && digits[0] == '0'))) {
        sign = 0;
    }

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45995>
_______________________________________


More information about the Python-bugs-list mailing list