rem_euclid
fn rem_euclid(int a, int b) -> int Import
Source: use num::{rem_euclid}; src/num.hy Returns the remainder of a / b that is never negative: 0 <= r < abs(b).
Unlike %, whose result takes the sign of a. Panics with division by zero when b is 0.
Parameters#
| Name | Type |
|---|---|
a | int |
b | int |
Returns#
int
Examples#
use num::{rem_euclid};
use tests::assert;
assert!(rem_euclid(-7, 3) == 2);
assert!(-7 % 3 == -1);
See also#
abs: Returns the absolute value ofx.min: Returns the smaller ofaandb(awhen they are equal).max: Returns the larger ofaandb(awhen they are equal).round: Roundsxto the nearest whole number; halves round away from zero.clamp: Returnsxlimited to the rangelo..=hi.signum: Returns-1,0or1by the sign ofx.gcd: Returns the greatest common divisor ofaandb, which should be non-negative.lcm: Returns the least common multiple ofaandb, which should be non-negative;0when either is0.