No ValueError for large exponents?

Felipe Almeida Lessa felipe.lessa at gmail.com
Sun Sep 10 08:30:08 EDT 2006


2006/9/6, Robin Becker <robin at nospamreportlab.com>:
> enigmadude wrote:
> > As many have heard, IronPython 1.0 was released. When I was looking
> > through the listed differences between CPython and IronPython, the
> > document mentioned that using large exponents such as 10 **
> > 735293857239475 will cause CPython to hang, whereas IronPython will
> > raise a ValueError. Trying this on my own machine, it did indeed seem
> > to cause CPython to hang. In cases such as this, should this be
> > considered a bug in the CPython implementation that needs to be fixed?
> > Or is there a reason for this, such as consideration of future changes
> > and language definition vs language implementation, etc.?
> >
> I suspect the hang may be python actually trying to work out the
> 1 followed by 735293857239475 zeroes. Perhaps IronPython has a forward
> looking algorithm that knows when to give up early.

I think that IronPython does the same as the .Net runtime does. Look
at boo's output:

$ booish
Welcome to booish, an interpreter for the boo programming language.

Running boo 0.7.5.2013.

The following builtin functions are available:
    dir(Type): lists the members of a type
    help(Type): prints detailed information about a type
    load(string): evals an external boo file
    globals(): returns the names of all variables known to the interpreter

Enter boo code in the prompt below.
>>> 10**100
1E+100
>>> 10**1000000
∞
>>> 10**735293857239475
ERROR: Error reading from 'input3': 'Value too large or too small.'.
>>> (10**100).GetType()
System.Double

Well, it's a double on boo instead of a very long int as in Python. I
don't know if in IronPython it's the same.

-- 
Felipe.


More information about the Python-list mailing list