mpz_invert (x, 1, 0)

Torbjorn Granlund tg at gmplib.org
Sat Mar 3 19:00:42 CET 2012


bodrato at mail.dm.unipi.it writes:

  Again, Niels propose an elegant way out: we can let inverses mod 0
  undefined. To obtain this we can keep the old library code, and patch only
  the recent testing program and documentation.
  
  I vote for this option.
  
Me too.

"The behaviour of computations modulo 0 is defined as being undefined."

:-)

  What should we do with mpz_powm, and mpz_powm_ui? The code for both
  functions starts with:
  
    n = ABSIZ(m);
    if (n == 0)
      DIVIDE_BY_ZERO;
  
Would you want to change that?

Just because something is undefined, does not mean we have to expose
users to some release-for-release changing crash.  Predictably crashing
in a way that can be caugth (by means of signal handling) is best.

-- 
Torbjörn


More information about the gmp-devel mailing list