integer overflow

C

Chad Haynes

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?

-Chad
 
J

Jp Calderone

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
 
M

Michael Hudson

Chad Haynes said:
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?

Is lst an array.array('h') or something (numarray...)?

Cheers,
mwh
 
C

Chad Haynes

Michael said:
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?


Is lst an array.array('h') or something (numarray...)?

Nope, its just a regular list
 
M

Michael Hudson

Chad Haynes said:
Michael said:
Chad Haynes said:
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?
Is lst an array.array('h') or something (numarray...)?

Nope, its just a regular list

Code, please.

Cheers,
mwh
 
T

Terry Reedy

Chad Haynes said:
Michael said:
Chad Haynes said:
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?


Is lst an array.array('h') or something (numarray...)?

Nope, its just a regular list

Suggestion: open interactive window, type in minimal lines of code needed
to reproduce error, then cut and post entire window, including header that
identifies your particular binary. Also mention the source of binary (who
compiled, you or someone else).

TJR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top