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
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel