Trait typed_floats::DivEuclid
source · pub trait DivEuclid<T> {
type Output;
// Required method
fn div_euclid(self, rhs: T) -> Self::Output;
}
Expand description
This trait is used to specify the return type of the DivEuclid::div_euclid()
function.
Required Associated Types§
sourcetype Output
type Output
The resulting type after applying DivEuclid::div_euclid()
.
Required Methods§
sourcefn div_euclid(self, rhs: T) -> Self::Output
fn div_euclid(self, rhs: T) -> Self::Output
Calculates Euclidean division, the matching method for rem_euclid
.
Equal to self if the sign of self and sign are the same, otherwise equal to -self.
This computes the integer n
such that
self = n * rhs + self.rem_euclid(rhs)
.
In other words, the result is self / rhs
rounded to the integer n
such that self >= n * rhs
.
§Examples
let a: NonNaN = 7.0.try_into().unwrap();
let b: NonNaN = 4.0.try_into().unwrap();
assert_eq!(a.div_euclid(b), 1.0);
assert_eq!((-a).div_euclid(b), -2.0);
assert_eq!(a.div_euclid(-b), -1.0);
assert_eq!((-a).div_euclid(-b), 2.0);
See f64::div_euclid()
for more details.