Ciao Niels, 17 feb 2024, 21:26 da ni...@lysator.liu.se:
> marco.bodr...@tutanota.com writes: > >> Maybe we should also add the test: >> >> /* Require that s==0 iff g==abs(b) */ >> if (!mpz_sgn (s) ^ !mpz_cmpabs (g, b)) >> goto fail; >> > > Good point, that's better than only checking the special case |a| == > |b|. (But maybe more readable with != instead of ^). > Yes, with != it's more readable! > To get mini-gmp to conform, I find no simpler way than special casing s > == 0, like > s==0 is not a special case, it's one of the cases with smaller |s|. What about; /* Arrange so that |s| < |u| / 2g */ mpz_add (s1, s0, s1); { int cmp = mpz_cmpabs (s0, s1); if (cmp >= 0) { mpz_swap (s0, s1); mpz_sub (t1, t0, t1); if (cmp != 0 || mpz_cmpabs (t0, t1) > 0) mpz_swap (t0, t1); } } Ĝis, m _______________________________________________ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs