Skip to content
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

ENH: issue overflow warning when using abs on np.int8(-128) #21648

Merged
merged 18 commits into from
Jun 13, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions numpy/core/src/umath/scalarmath.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,15 @@ static NPY_INLINE int
/**begin repeat
* #name = byte, short, int, long, longlong#
* #type = npy_byte, npy_short, npy_int, npy_long, npy_longlong#
* #NAME = BYTE, SHORT, INT, LONG, LONGLONG#
*/
static NPY_INLINE int
@name@_ctype_absolute(@type@ a, @type@ *out)
{
*out = (a < 0 ? -a : a);
if (a < 0 && a == NPY_MIN_@NAME@) {
Micky774 marked this conversation as resolved.
Show resolved Hide resolved
return NPY_FPE_OVERFLOW;
}
Micky774 marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}
/**end repeat**/
Expand Down