Should I use mod or remainder when checking a BigInteger for divisibility?

Viewed 2721

When checking a BigInteger a for divisibility by some BigInteger b, I can write either a.mod(b).equals(BigInteger.ZERO) or a.remainder(b).equals(BigInteger.ZERO).

Which of the two expressions is more efficient?

EDIT: Several people have correctly pointed out that mod doesn't accept a negative modulus. Please assume that b is positive in your answer.

4 Answers
Related