Skip to main content

modulo

Function modulo 

Source
pub fn modulo(x: f64, y: f64) -> f64
Expand description

(fmod) Returns the floating-point remainder of x/y

The magnitude of the result is less than y and its sign agrees with that of x

See also: https://cplusplus.com/reference/cmath/fmod/

§Special cases

  • modulo(±Inf, y) = NaN
  • modulo(NaN, y) = NaN
  • modulo(x, 0) = NaN
  • modulo(x, ±Inf) = x
  • modulo(x, NaN) = NaN

§Examples

use russell_lab::{approx_eq, math};

approx_eq(math::modulo( 5.3, 2.0), 1.3, 1e-15);
approx_eq(math::modulo(18.5, 4.2), 1.7, 1e-15);