Skip to main content

primitive_float_rem_rational_and_quotient_bits

Function primitive_float_rem_rational_and_quotient_bits 

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

Computes the remainder of a primitive float by a Rational along with the low bits of the quotient, with the quotient rounded toward zero, correctly rounding the remainder to the nearest value.

The Rational modulus is used exactly.

§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_rem_rational_and_quotient_bits;
use malachite_q::Rational;

let (r, q) =
    primitive_float_rem_rational_and_quotient_bits(10.0, &Rational::from_signeds(22, 7));
assert_eq!(NiceFloat(r), NiceFloat(0.5714285714285714));
assert_eq!(q, 3);