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 mamrhein
Recipients eric.smith, facundobatista, mamrhein, mark.dickinson, rhettinger, skrah
Date 2019-12-17.22:35:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576622143.15.0.0183250114771.issue39077@roundup.psfhosted.org>
In-reply-to
Content
>
> ... Has anyone checked what C does?
>

#include <stdio.h>
int main() {
    int i = -12345;
    double f = -12345.0;
    printf("%-020d\n", i);
    printf("%020d\n", i);
    printf("%20d\n", i);
    printf("%-020f\n", f);
    printf("%020f\n", f);
    printf("%20f\n", f);
    return 0;
}

Output:

-12345             
-0000000000000012345
              -12345
-12345.000000      
-000000012345.000000
       -12345.000000

https://en.cppreference.com/w/c/io/fprintf:

Each conversion specification has the following format:

  introductory % character 

  (optional) one or more flags that modify the behavior of the conversion: 

    -: the result of the conversion is left-justified within the field (by default it is right-justified)
    +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative)
    space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.
    # : alternative form of the conversion is performed. See the table below for exact effects otherwise the behavior is undefined.
    0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For integer numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present. 

Last sentence means that zero-padding is only done when the output is right-aligned. I can't find an equivalent for Pythons '=' align option.
History
Date User Action Args
2019-12-17 22:35:43mamrheinsetrecipients: + mamrhein, rhettinger, facundobatista, mark.dickinson, eric.smith, skrah
2019-12-17 22:35:43mamrheinsetmessageid: <1576622143.15.0.0183250114771.issue39077@roundup.psfhosted.org>
2019-12-17 22:35:43mamrheinlinkissue39077 messages
2019-12-17 22:35:43mamrheincreate