mmod_gmp#

Return the non-negative remainder of $a / $b.

Synopsis#

Math::GMP->new(-7)->mmod_gmp(3);       # 2, not -1

Unlike % on Math::GMP (which uses truncated division and follows the sign of the dividend), mmod_gmp always returns a result in [0, abs($b)). This matches the mathematical “mod” operation used in number-theory work.