in h3_coordijk.c [217:246]
bool _ijkNormalizeCouldOverflow(const CoordIJK *ijk) {
// Check for the possibility of overflow
int max, min;
if (ijk->i > ijk->j) {
max = ijk->i;
min = ijk->j;
} else {
max = ijk->j;
min = ijk->i;
}
if (min < 0) {
// Only if the min is less than 0 will the resulting number be larger
// than max. If min is positive, then max is also positive, and a
// positive signed integer minus another positive signed integer will
// not overflow.
if (ADD_INT32S_OVERFLOWS(max, min)) {
// max + min would overflow
return true;
}
if (SUB_INT32S_OVERFLOWS(0, min)) {
// 0 - INT32_MIN would overflow
return true;
}
if (SUB_INT32S_OVERFLOWS(max, min)) {
// max - min would overflow
return true;
}
}
return false;
}