gmpy
gmpy copied to clipboard
"Invalid conversion specification" error for align '=' value in format spec
>>> from gmpy2 import *
>>> f"{mpfr('123.456'):=.5g}"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid conversion specification
>>> f"{float(mpfr('123.456')):=.5g}" # works for python floats
'123.46'
I think we should be compatible with python floats here, meaning '=' is: "Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form ‘+000000120’. This alignment option is only valid for numeric types. It becomes the default for numbers when ‘0’ immediately precedes the field width."