-
-
Notifications
You must be signed in to change notification settings - Fork 11k
overflow not caught on operators with int32 array (Trac #2133) #593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is unrelated to #2350; the overflow checking code for floating point and integers is totally different. (The former relies on some special IEEE-754 features that can only be accessed through platform specific code and #2350 is that apparently our platform specific code is buggy; integer overflow is checked directly by hand in our own C code. grep for The bug here is very simple: we have two complete sets of arithmetic functions for integers, one in |
I presume in addition to int32, this bug can be generalised to cover the other integer types, e.g. uint8 (as shown in my example below), int8, uint16, int16, uint32, int64, uint64
In this use case, I am working with the topology of a graph allowing multiple edges held as an integer adjacency matrix, A. I would calculate things like A^n for paths of length n, and also make changes to A directly (e.g. adding edges). The motivation to use the low range types like np.uint8 (unsigned) is to limit the memory while working with large networks. In this usage I do not need negative entries. See http://mail.scipy.org/pipermail/numpy-discussion/2013-January/064948.html and http://mail.scipy.org/pipermail/numpy-discussion/2013-January/064949.html |
@peterjc: Right, if you look at scalarmathmodule.c.src and loops.c.src you'll see that all that the code for all the different integer widths is generated from the same template, so whatever applies to one width applies to all. |
duplicate of #8987, since there is more discussion there should we close this one? |
Closing as duplicate of gh-8987 as mentioned already by Matti (integer overflow issue). |
Original ticket http://projects.scipy.org/numpy/ticket/2133 on 2012-05-16 by trac user mwtoews, assigned to unknown.
I see good overflow warnings operations on int32 scalars, but not for int32 arrays:
Here is what I can determine between operator op between arrays or scalars:
I would expect an overflow runtime warning for cases 2 and 3, similar to case 4.
These results are with NumPy 1.6.1/Python 2.5.1 on Windows 32-bit, which I installed from
numpy-unoptimized-1.6.1.win32-py2.5.exe
from [http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy ~gohlke], but are reproducible on 64-bit Linux.The text was updated successfully, but these errors were encountered: