Arbitrary-precision multiple-precision floats in Python: mpmath, gmpy, sympy .evalf() / N()
Python library for arbitrary-precision floating-point arithmetic
- docs: http://mpmath.org/doc/current/ - mpmath is used by SymPy and Sage - mpmath uses gmpy if it's installed (otherwise Python ints)
General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR,
MPC) - docs: https://gmpy2.readthedocs.io/en/latest/ - Integers, Rationals, Reals, Complex
Exact SymPy expressions can be converted to floating-point approximations
(decimal numbers) using either the .evalf() method or the N() function.
[...] By default, numerical evaluation is performed to an accuracy of 15
decimal digits. You can optionally pass a desired accuracy (which should be a positive integer) as an argument to evalf or N:
On Sat, Oct 10, 2020 at 3:34 PM Marco Sulla Marco.Sulla.Python@gmail.com wrote:
On Sat, 10 Oct 2020 at 19:28, Tim Peters firstname.lastname@example.org wrote:
Try to spell out what you mean - precisely! - by "this". I can't do that for you. For any plausible way of fleshing it out I've thought of, the answer is "no".
Well, please, don't be so harsh. I'm trying to discuss to someone that co-created Python itself, it's not simple to me :-P
The closest you can get to BigDecimal's behavior "by magic" in Python is to set the context precision to its maximum allowed value.
I think there's another "trick" to get the BigDecimal behaviour. If you read the Javadoc, it says that each operation has a default precision. For example, multiplication a*b has precision = a_scale + b_scale. So, in reality, also BigDecimal has a context with finite precision. The difference is that the default context has a variable precision, depending on the operation.
Could Python decimal have something similar, maybe by setting prec = -1? _______________________________________________ Python-ideas mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://email@example.com/message/O7KUAR... Code of Conduct: http://python.org/psf/codeofconduct/