Skip to main content

primitive_float_ieee_remainder

Function primitive_float_ieee_remainder 

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

Computes the IEEE 754 remainder of two primitive floats, with the quotient rounded to the nearest integer (ties to even), using emulated Float arithmetic.

Like the truncated-quotient remainder, this value is always exactly representable. NaN, infinite x, or zero y gives NaN; a zero remainder has the sign of x.

§Worst-case complexity

Constant time and additional memory.

§Examples

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

assert_eq!(
    NiceFloat(primitive_float_ieee_remainder(14.0, 3.0)),
    NiceFloat(-1.0)
);