This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Arbitrary precision
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.7
process
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 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg123414 - (view) Author: Bill McEachen (billymac00) Date: 2010-12-05 08:43
from this link [http://en.wikipedia.org/wiki/PARI/GP#Usage_examples], 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.
479001600.0
>>> math.factorial(123) +0.
1.214630436702533e+205
>>> 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.
History
Date User Action Args
2022-04-11 14:57:09adminsetgithub: 54838
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