18007, "lydia-duncan", "[Library stabilization] Should the BigInteger division methods throw an error when dividing by zero?", "2021-06-30T17:51:03Z"
In writing the documentation for bigint.divQ()
, I noticed that the GMP documentation says:
Division is undefined if the divisor is zero. Passing a zero divisor to the division or modulo functions (including the modular powering functions mpz_powm and mpz_powm_ui), will cause an intentional division by zero. This lets a program handle arithmetic exceptions in these functions the same way as for normal C int arithmetic.
Since the BigInteger module is intended to be more independent of the C API, I don't think it's appropriate to reference C in the documentation for these modules. We've also received feedback in the past that libraries should not cause user programs to abruptly terminate. Does that imply that our implementations for these functions should check for division by 0 and throw an error when it would happen?