Skip to main content

primitive_float_rem_and_quotient_bits

Function primitive_float_rem_and_quotient_bits 

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

Computes the remainder of two primitive floats along with the low bits of the quotient, with the quotient rounded toward zero, using emulated Float arithmetic.

This is the analog of C’s fmodquo-style functions: the i64 agrees with the exact quotient $q$ in its low 63 bits and has $q$’s sign.

§Worst-case complexity

Constant time and additional memory.

§Examples

use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::rem::primitive_float_rem_and_quotient_bits;

let (r, q) = primitive_float_rem_and_quotient_bits(100.0, 7.0);
assert_eq!(NiceFloat(r), NiceFloat(2.0));
assert_eq!(q, 14);