[IronPython] Bug of big integer manipulation

HEMMI, Shigeru textdirected at gmail.com
Wed Aug 9 01:30:51 CEST 2006


Hello,

NZMATH is a Python based number theory oriented calculation system
developed by Tokyo Metropolitan University. The URL is
http://tnt.math.metro-u.ac.jp/nzmath/.

Using NZMATH, I encounterd a bug of big integer manipulation.

IronPython
============================
C:\IronPython-2604>ipy
IronPython 1.0.2411 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys.path.append(r'C:\Python24\Lib')
>>> sys.path.append(r'C:\Python24\Lib\site-packages')
>>> from nzmath import prime
>>> prime.nextPrime(256)
257
>>> nx = sys.maxint
>>> prime.nextPrime(nx*nx)
Traceback (most recent call last):
  File , line 0, in <stdin>##115
  File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime
  File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq
  File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp
  File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp
ValueError: value too big
>>> prime.nextPrime(nx)  ## Seems going into infinite loop.

CPython
============================
C:\IronPython-2604>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from nzmath import prime
>>> nx = sys.maxint
>>> prime.nextPrime(nx*nx)
4611686014132420667L
>>> prime.nextPrime(nx)
2147483659L
>>>

Regards,



More information about the Ironpython-users mailing list