You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating-point value formatted with 'f' and 'F', or before and after the decimal point for a floating-point value formatted with 'g' or 'G'. For non-number types the field indicates the maximum field size - in other words, how many characters will be used from the field content. The precision is not allowed for integer values.
So I tried to use precision on a string argument, for example:
Fixed in 43aebf5. As for "precision" for integer arguments, the fmt::format function follows Python's conventions in not allowing it, but as in Python you can use a combination of fill and width for similar effect:
fmt::format("{:05}", 42); // returns "00042"
or use fmt::sprintf which follows printf conventions and allows precision for integer arguments.
Activity
vitaut commentedon Jan 7, 2015
Good catch, I'll have a look into this. Thanks!
vitaut commentedon Jan 8, 2015
Fixed in 43aebf5. As for "precision" for integer arguments, the
fmt::formatfunction follows Python's conventions in not allowing it, but as in Python you can use a combination of fill and width for similar effect:or use
fmt::sprintfwhich followsprintfconventions and allows precision for integer arguments.lahwaacz commentedon Jan 11, 2015
Thanks, I was not aware of Python's approach so in that case everything is all right...