Skip to main content

primitive_float_ieee_remainder_rational

Function primitive_float_ieee_remainder_rational 

Source
pub fn primitive_float_ieee_remainder_rational<T>(x: T, y: &Rational) -> T
where Float: From<T> + PartialOrd<T>, for<'a> T: ExactFrom<&'a Float> + PrimitiveFloat,
Expand description

Computes the IEEE 754 remainder of a primitive float by a Rational, with the quotient rounded to the nearest integer (ties to even), correctly rounding the result to the nearest value.

The Rational modulus is used exactly; see primitive_float_rem_rational for why this matters.

§Worst-case complexity

$T(n) = O(n \log n \log\log n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is y.significant_bits().

§Examples

use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::rem::primitive_float_ieee_remainder_rational;
use malachite_q::Rational;

assert_eq!(
    NiceFloat(primitive_float_ieee_remainder_rational(
        10.0,
        &Rational::from_signeds(22, 7)
    )),
    NiceFloat(0.5714285714285714)
);