At first, I liked the "isDivisibleByPowerof2" because it seemed more readable, but that was based on an assumption that it was answering the question "is it divisible by some power of 2". Reading the GMP page, I think I'm understanding it to take
k as an argument and to answer the question "is it divisible by 2**k" (?).
With that understanding, I think that
myBigInt.isDivisibleBy2exp(k) reads slightly nicer, though I don't think we use
exp in this way in other places that I can think of (since
** would be the infix operator and 2 is embedded in the method name). So another alternative would be
myBigInt.isDivisibleBy2pow(k) which reads slightly cleaner to me.
However, that has the downside of not working as nicely for
congruent_2exp_p I think because another argument would come between the
( and the
This is a case where I'd look at other languages that provide a pretty interface to GMP via a bigint type to see whether they've come up with something clever that I'm not thinking of.
[edit: PS — "jinx" Ben! ]