pub fn rem_euclid(dividend: i64, divisor: i64) -> VMResult<i64>
Expand description
Usage: (rem_euclid int int)
Least Non-negative number that can be added to a multiple of the divisor (arg 2) to get the dividend (arg 1).
The result should always be 0 <= result < divisor (arg 2).
Note: Remainder and Modulo are two similar mathematical operations,
called rem
and rem_euclid
in Rust.
With rem
, the sign of the result is the same as the dividend (arg 1).
With rem_euclid
, the sign of the result is always positive.
Section: math
Example: (test::assert-equal 0 (rem_euclid 50 10)) (test::assert-equal 5 (rem_euclid 55 10)) (test::assert-equal 1 (rem_euclid 1 2)) (test::assert-equal 2 (rem_euclid -10 3)) (test::assert-equal 1 (rem_euclid 10 -3)) (test::assert-equal 2 (rem_euclid -10 -3))
(test::assert-error (rem_euclid)) (test::assert-error (rem_euclid 1)) (test::assert-error (rem_euclid 1 2 3)) (test::assert-error (rem_euclid 1 2.0))