Skip to main content

primitive_float_rem

Function primitive_float_rem 

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

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

The floating-point remainder of two values of the same format is always exactly representable, so this function returns the same values as the % operator on primitive floats; it serves as a reference implementation. 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_rem;

assert_eq!(NiceFloat(primitive_float_rem(10.0, 7.0)), NiceFloat(3.0));
assert_eq!(NiceFloat(primitive_float_rem(10.5, 3.25)), NiceFloat(0.75));