MCPcopy Create free account
hub / github.com/numpy/numpy / safe_add

Function safe_add

numpy/core/src/common/npy_extint128.h:12–22  ·  view source on GitHub ↗

Integer addition with overflow checking */

Source from the content-addressed store, hash-verified

10
11/* Integer addition with overflow checking */
12static inline npy_int64
13safe_add(npy_int64 a, npy_int64 b, char *overflow_flag)
14{
15 if (a > 0 && b > NPY_MAX_INT64 - a) {
16 *overflow_flag = 1;
17 }
18 else if (a < 0 && b < NPY_MIN_INT64 - a) {
19 *overflow_flag = 1;
20 }
21 return a + b;
22}
23
24
25/* Integer subtraction with overflow checking */

Callers 3

diophantine_precomputeFunction · 0.85
solve_diophantineFunction · 0.85
diophantine_simplifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected