Python Forum

Full Version: Large Number Math
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(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.
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.