diff --git a/c-programming/math/opt_int_div.h b/c-programming/math/opt_int_div.h index 6b3a90c..24e594f 100644 --- a/c-programming/math/opt_int_div.h +++ b/c-programming/math/opt_int_div.h @@ -33,6 +33,10 @@ /* the result is +/-1 */ \ (INT_DIV_NEG_RESULT_SIGN(a, b) ? -1 : 1) : ( \ \ + /* check if abs(a) < abs(b) */ \ + INT_ABS((a)) < INT_ABS((b)) ? \ + 0 : ( \ + \ /* check if b is a power of 2 */ \ /* */ \ /* formula: round(log_2(b) % 1, OPT_INT_DIV_TEST_PRECISION digits */ \ @@ -44,5 +48,5 @@ : \ INT_BIN_DIV(INT_ABS(a), INT_ABS(b))) \ : \ - ((a) / (b)) ) \ + ((a) / (b)) )) \ ) /* end */