Python Forum
Large Number Math - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Large Number Math (/thread-14226.html)



Large Number Math - fibonacci - Nov-20-2018

Hi all,

I'm trying to write a calculator to help me with some research that I am doing. I only need the following basic math functions (multiply, divide, add, subtract, square root) but I need exact precision. Also, I am only looking for precise integers, any results with a decimal value are discarded. I have tried utilizing the decimal library but I am running into errors with it, it seems that unless I know the exact level of decimal precision required for each calculation the decimal functions have a tendency to return inaccurate numbers.

Is there a better way to do this? Speed of processing is not so much a factor as accuracy is.


RE: Large Number Math - nilamo - Nov-20-2018

(Nov-20-2018, 07:15 PM)fibonacci Wrote: but I am running into errors with it

The decimal module is the way to get accuracy, so share your errors please.


RE: Large Number Math - Gribouillis - Nov-20-2018

You can also use the Gnu multiprecision library by installing the gmpy2 module. For advanced number theory, you can also use the PARI/GP computer algebra system by installing a module such as cypari or cypari2.