integer overflow

Jp Calderone exarkun at intarweb.us
Thu Feb 5 11:09:21 EST 2004


On Thu, Feb 05, 2004 at 10:58:28AM -0500, Chad Haynes wrote:
> I got an odd error which I cannot explain and cannot seem to reproduce.
> The following statement
> 
> 	lst[0] = num
> 
> produced this error
> 
> 	OverflowError: unsigned short is greater than maximum
> 
> The number was around 65536 so it makes sense that it would overflow a 
> short, but why is it trying to force it into a short integer?

    >>> import array
    >>> a = array.array('h', [0])
    >>> a[0] = 10000000
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    OverflowError: signed short integer is greater than maximum

  Jp





More information about the Python-list mailing list