1

I have a question towards the pure math support of Python. As far as I know, at some point the calculation is not precise enough in Python, given that the operands are large enough.

Is there some kind of unlimited precision support in Python the language itself, rather than importing a library like numpy? I'm asking for something like BigDecimal in Java, which supports unlimited precision of decimal calculation.

6
  • How about bigfloat? Commented Oct 8, 2014 at 15:24
  • 1
    Have you looked at the decimal module? docs.python.org/2/library/decimal.html Commented Oct 8, 2014 at 15:25
  • Thank you both! I think the decimal module @tom suggested is the one I want. Please convert it to an answer? Commented Oct 8, 2014 at 15:35
  • @SergeBallesta I understand that unlimited integer precision is supported by Python, which is a very cool feature. However what I want is a kind of calculation that does not lose precision in the process, for example if I take square root of 3999999995999999997 I get 1999999999.0, and if take the square of the result I get 3999999996000000001L. Commented Oct 8, 2014 at 15:41
  • @AlbusShin I've converted it. Commented Oct 8, 2014 at 15:59

2 Answers 2

1

Have you looked at the decimal module? https://docs.python.org/2/library/decimal.html

Sign up to request clarification or add additional context in comments.

Comments

1

For python native decimal.Decimal & fractions.Fraction performance once harnessed inside numpy dense-matrix ( sparse-matrix est'd ) computations -- quantitative performance comparison -- kindly ref. >>> https://stackoverflow.com/a/26248202/3666197

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.