Module malachite_base::num::arithmetic::reciprocal

source ·
Expand description

Reciprocal and ReciprocalAssign, traits for computing the reciprocal (multiplicative inverse) of a number.

§reciprocal

use malachite_base::num::arithmetic::traits::Reciprocal;

assert_eq!(0.0f32.reciprocal(), f32::INFINITY);
assert_eq!(1.5f32.reciprocal(), 0.6666667);

§reciprocal_assign

use malachite_base::num::arithmetic::traits::ReciprocalAssign;

let mut x = 0.0f32;
x.reciprocal_assign();
assert_eq!(x, f32::INFINITY);

let mut x = 1.5f32;
x.reciprocal_assign();
assert_eq!(x, 0.6666667);