Function div_euclid

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

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

§Examples

#![feature(core_float_math)]

use core::f32;

let a: f32 = 7.0;
let b = 4.0;
assert_eq!(f32::div_euclid(a, b), 1.0); // 7.0 > 4.0 * 1.0
assert_eq!(f32::div_euclid(-a, b), -2.0); // -7.0 >= 4.0 * -2.0
assert_eq!(f32::div_euclid(a, -b), -1.0); // 7.0 >= -4.0 * -1.0
assert_eq!(f32::div_euclid(-a, -b), 2.0); // -7.0 >= -4.0 * 2.0

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