Function in num coil-stdlib

rem_euclid

fn rem_euclid(int a, int b) -> int
Import
use num::{rem_euclid};
Source: 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#

NameType
aint
bint

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 of x.
  • min: Returns the smaller of a and b (a when they are equal).
  • max: Returns the larger of a and b (a when they are equal).
  • round: Rounds x to the nearest whole number; halves round away from zero.
  • clamp: Returns x limited to the range lo..=hi.
  • signum: Returns -1, 0 or 1 by the sign of x.
  • gcd: Returns the greatest common divisor of a and b, which should be non-negative.
  • lcm: Returns the least common multiple of a and b, which should be non-negative; 0 when either is 0.
↑ ↓ navigate ↵ open