mpz_prevprime
Marco Bodrato
bodrato at mail.dm.unipi.it
Fri Oct 16 14:32:18 UTC 2020
Ciao,
Il 2020-10-16 09:51 Seth Troisi ha scritto:
> won't this cause m = 2*prime, instead of the original result, m = 0?
> I used m = (diff > 0 && m) ? prime - m : m;
> to make sure that p can be marked as composite.
Oops, you are right!
I fear that the short-circuit evaluation of && can force the compiler to
branch...
(diff > 0) & (m != 0) should be computed branchless...
But that's a stupid detail, as you said most of the time is used in the
mod function or in millerrabin :-)
Ĝis,
m
More information about the gmp-devel
mailing list