Title: Arbitrary precision
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: billymac00, georg.brandl, mark.dickinson
Priority: normal Keywords:

Created on 2010-12-05 08:43 by billymac00, last changed 2010-12-05 13:05 by mark.dickinson. This issue is now closed.

Messages (3)
msg123414 - (view) Author: Bill McEachen (billymac00) Date: 2010-12-05 08:43
from this link [], I wanted to contrast arbitrary precision with the other pgm I use, Pari/GP.  I tried the xample there which was:
123456! + 0.
Now, behavior seems the same without the "+0." for both.  However, while Pari returns the answer shown on link quickly, Python after a delay returned an error, related to float conversion.  Here is the progression from a smaller number to the problem:
>>> math.factorial(12) +0.
>>> math.factorial(123) +0.
>>> math.factorial(1234) +0.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to float
msg123422 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-12-05 12:28
Note that while Python's long type gives you unlimited-size integers, the float type doesn't make such promises: it is just a double-precision float.  As such, math.factorial(1234) cannot be interpreted; it would simply be positive infinity.
msg123423 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-12-05 13:05
Right; this is expected behaviour.  The error you're seeing comes from the implicit conversion of 1234! from long to float.
Date User Action Args
2010-12-05 13:05:18mark.dickinsonsetstatus: pending -> closed

messages: + msg123423
2010-12-05 12:28:25georg.brandlsetstatus: open -> pending

nosy: + mark.dickinson, georg.brandl
messages: + msg123422

components: + Interpreter Core, - Regular Expressions
resolution: not a bug
2010-12-05 08:43:15billymac00create