Function rem_euclid

Source
pub fn rem_euclid(x: f32, rhs: f32) -> f32
🔬This is a nightly-only experimental API. (core_float_math)
Expand description

Experimental version of rem_euclid in core. See f32::rem_euclid for details.

§Examples

#![feature(core_float_math)]

use core::f32;

let a: f32 = 7.0;
let b = 4.0;
assert_eq!(f32::rem_euclid(a, b), 3.0);
assert_eq!(f32::rem_euclid(-a, b), 1.0);
assert_eq!(f32::rem_euclid(a, -b), 3.0);
assert_eq!(f32::rem_euclid(-a, -b), 1.0);
// limitation due to round-off error
assert!(f32::rem_euclid(-f32::EPSILON, 3.0) != 0.0);

This standalone function is for testing only. It will be stabilized as an inherent method.