473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

integer overflow

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
Jul 18 '05 #1
5 5909
Chad Haynes <ha*****@rockefeller.edu> 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
Jul 18 '05 #2
Michael Hudson wrote:
Chad Haynes <ha*****@rockefeller.edu> 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

Jul 18 '05 #3
Chad Haynes <ha*****@rockefeller.edu> writes:
Michael Hudson wrote:
Chad Haynes <ha*****@rockefeller.edu> 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
Jul 18 '05 #4
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
Jul 18 '05 #5

"Chad Haynes" <ha*****@rockefeller.edu> wrote in message
news:_L********************@news.rockefeller.edu.. .
Michael Hudson wrote:
Chad Haynes <ha*****@rockefeller.edu> 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

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Black | last post by:
Hi, If I have many integer calculation in my code, what's the best way to detect integer overflow? unsigned int i1 = 0xFFFFFF00, i2 = 0xFFFF; then in statement unsigned int i3 = i1 + i2;...
2
by: REH | last post by:
If the is_modulo field of the numeric_limits class is true for signed integer types, can I assume that overflow for such types is defined behavior? If so, is the behavior the same regardless of...
25
by: Ashutosh Iddya | last post by:
Hi , I am performing an integer count of a particular operation in my program. After a sufficiently large value an overflow occurs. At the moment I have gone around the problem by declaring it...
25
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do...
9
by: Chris Botha | last post by:
Hi, I have an UInt32 and want to stick the value into an Integer and get an Overflow exception, BUT using C# the same value can be casted into an int and the value is as expected. The Hex value is...
40
by: Robert Seacord | last post by:
The CERT/CC has released a beta version of a secure integer library for the C Programming Language. The library is available for download from the CERT/CC Secure Coding Initiative web page at:...
13
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I...
42
by: thomas.mertes | last post by:
Is it possible to use some C or compiler extension to catch integer overflow? The situation is as follows: I use C as target language for compiled Seed7 programs. For integer computions the C...
6
by: Chris Becke | last post by:
I *know* my CPU has opcodes that can do this - when adding (or subtracting) there is a carry flag that can be invoked to make the result essentially 1 bit longer than the data size used in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.