aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
518 stars 86 forks source link

Change defaults for format-style printing? #506

Open skirpichev opened 2 months ago

skirpichev commented 2 months ago

Documentation says: The default format is '.6f'. While this can be considered as a feature, I would prefer to be compatible with CPython floats here (in short, in CPython default is almost same as 'g').

With 'f' it's easy to demolish significand to dust:

>>> f'{gmpy2.mpfr(1.3335678912e-10)}'
'0.000000'
>>> f'{gmpy2.mpfr(1.3335678912e-10):g}'
'1.33357e-10'
casevh commented 1 month ago

I agree that matching CPython is important. I don't remember why I chose '.6f'.