Implement 'a'/'A' formating types for mpf.__format__#841
Implement 'a'/'A' formating types for mpf.__format__#841skirpichev merged 1 commit intompmath:masterfrom
Conversation
8b79d83 to
928f216
Compare
|
See also python/cpython#113804. Potentially, we could reuse 'x'/'X' format codes, but I think it's a good idea to be compatible with gmpy2 (and C) here. |
|
I
Yes, I think it's better to use 'a' and 'A'. |
|
I'm not a specialist in hex numbers but >>> import gmpy2
>>> gmpy2.get_context().precision = 5300
>>> print(f"{gmpy2.mpfr('1.234567890123456789'):.20a}") # This one is the same as gmpy2
0x1.3c0ca428c59fb71a4194p+0
>>> print(f"{gmpy2.mpfr('1.234567890123456789'):.0a}") # This one is different
0xap-3whereas, according to the tests you wrote, the latter one should return " |
It's not. The mpmath always use 1-normalization for normal numbers, while in the MPFR - the digit before decimal dot should be just non-zero. This is something they wish to fix, but... See https://sympa.inria.fr/sympa/arc/mpfr/2021-05/msg00002.html |
b9e4d93 to
0098455
Compare
6b24b5b to
6e8326a
Compare
cfeb6c4 to
f1427a4
Compare
f1427a4 to
40c16e9
Compare
See #337