Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > integer overflow

Reply
Thread Tools

integer overflow

 
 
Chad Haynes
Guest
Posts: n/a
 
      02-05-2004
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
 
Reply With Quote
 
 
 
 
Jp Calderone
Guest
Posts: n/a
 
      02-05-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


 
Reply With Quote
 
 
 
 
Michael Hudson
Guest
Posts: n/a
 
      02-05-2004
Chad Haynes <(E-Mail Removed)> writes:

> 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

--
An encyclopedia is about being as accurate as it can, not being
evenly misinformed. -- Coby Beck, comp.lang.lisp
 
Reply With Quote
 
Chad Haynes
Guest
Posts: n/a
 
      02-05-2004
Michael Hudson wrote:

> Chad Haynes <(E-Mail Removed)> writes:
>
>
>>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

>
> Cheers,
> mwh
>

 
Reply With Quote
 
Michael Hudson
Guest
Posts: n/a
 
      02-05-2004
Chad Haynes <(E-Mail Removed)> writes:

> Michael Hudson wrote:
>
> > Chad Haynes <(E-Mail Removed)> writes:
> >
> >>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

--
The snakes are optional, as are the electrodes, the molten lead
and the ritual buggering by syphilitic warthogs.
-- Tanuki the Raccoon-dog, asr
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      02-05-2004

"Chad Haynes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed).. .
> Michael Hudson wrote:
>
> > Chad Haynes <(E-Mail Removed)> writes:
> >> 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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
integer or long overflow... deancoo C++ 11 03-05-2005 11:13 PM
integer overflow Ashutosh Iddya C Programming 25 04-24-2004 06:16 PM
hhow to detect overflow in integer calculation John Black C++ 1 04-15-2004 05:28 AM
unsigned integer overflow behaviour bartek C++ 3 02-06-2004 09:47 PM
Integer overflow Enrico 'Trippo' Porreca C Programming 9 08-24-2003 10:24 AM



Advertisments