1

The mpmath library appears to be installed along with the rest of python been trying:

from mpmath import *

then think

x= mpf (65455213.0) etc could be miles off. Ultimately I need very accurate operations on very long numbers, time is not the primary concern. What is the correct syntax to declare numbers like this along with operations.

Kev88
  • 21
  • 5

1 Answers1

1

You're passing a Python float to the mpf constructor. That means that the number gets rounded to what a Python float can represent, throwing away precision before mpmath gets a chance to do anything.

Pass a string:

x = mpf("65455213.0")

Also, I would recommend not using import *.

user2357112
  • 260,549
  • 28
  • 431
  • 505
  • Ye its saying that this is an undefined name or no module named mpmath. sorry Im very new to python. What do I use? – Kev88 Mar 24 '16 at 17:33
  • @Kev88: If you're getting an error saying "No module named mpmath", when you were able to use mpmath before, you've screwed up your Python installation(s) somehow. Maybe you have two copies of Python installed and only one of them has mpmath. As for what you should be doing instead of `import *`, use `import mpmath` and then prefix mpmath things with `mpmath.`, like `mpmath.mpf`, or import specific module contents like `from mpmath import mpf`. – user2357112 Mar 24 '16 at 17:37
  • Ok maybe Iv missed somethin earlier. Im using spider, when I downloaded it the files containing mpmath were downloaded, Ive tried various suggestions of easy_install and the like but none work, is there something extra I should have done. Iv never had mpmath working – Kev88 Mar 24 '16 at 18:44