pub struct UnguardedF32(/* private fields */);Expand description
Represents a checked floating-point number that ensures it is neither NaN nor infinite.
§Example
use floatguard::{UnguardedF32, FloatError, GuardedF32};
let unchecked_f32 = UnguardedF32::new(1.0);
assert_eq!((unchecked_f32 + 1.0).check(), GuardedF32::new(2.0));
assert_eq!(unchecked_f32.check(), GuardedF32::new(1.0));
assert_eq!((unchecked_f32 - f32::INFINITY).check(), Err(FloatError::Infinity));Implementations§
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const RADIX: u32 = 2u32
pub const RADIX: u32 = 2u32
The radix or base of the internal representation of f32.
See: f32::RADIX
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MANTISSA_DIGITS: u32 = 24u32
pub const MANTISSA_DIGITS: u32 = 24u32
Number of significant digits in base 2.
See: f32::MANTISSA_DIGITS.
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const DIGITS: u32 = 6u32
pub const DIGITS: u32 = 6u32
Approximate number of significant digits in base 10.
See: f32::DIGITS.
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const EPSILON: GuardedF32
pub const EPSILON: GuardedF32
The difference between 1.0 and the next larger representable number. Equal to
21 − MANTISSA_DIGITS.
See: f32::EPSILON
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MIN: GuardedF32
pub const MIN: GuardedF32
Smallest finite f32 value.
See: f32::MIN
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MIN_POSITIVE: GuardedF32
pub const MIN_POSITIVE: GuardedF32
Smallest positive normal f32 value.
See: f32::MIN_POSITIVE
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MAX: GuardedF32
pub const MAX: GuardedF32
Largest finite f32 value.
See: f32::MAX
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MIN_EXP: i32 = -125i32
pub const MIN_EXP: i32 = -125i32
Minimum possible normal power of 2 exponent.
See: f32::MIN_EXP
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MAX_EXP: i32 = 128i32
pub const MAX_EXP: i32 = 128i32
Maximum possible normal power of 2 exponent.
See: f32::MAX_EXP
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MIN_10_EXP: i32 = -37i32
pub const MIN_10_EXP: i32 = -37i32
Minimum possible normal power of 10 exponent.
See: f32::MIN_10_EXP
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const MAX_10_EXP: i32 = 38i32
pub const MAX_10_EXP: i32 = 38i32
Maximum possible normal power of 10 exponent.
See: f32::MAX_10_EXP
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const PI: GuardedF32
pub const PI: GuardedF32
Archimedes’ constant (π)
See: std::f32::consts::PI
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const TAU: GuardedF32
pub const TAU: GuardedF32
The full circle constant (τ = 2π)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_PI_2: GuardedF32
pub const FRAC_PI_2: GuardedF32
π/2
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_PI_3: GuardedF32
pub const FRAC_PI_3: GuardedF32
π/3
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_PI_4: GuardedF32
pub const FRAC_PI_4: GuardedF32
π/4
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_PI_6: GuardedF32
pub const FRAC_PI_6: GuardedF32
π/6
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_PI_8: GuardedF32
pub const FRAC_PI_8: GuardedF32
π/8
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_1_PI: GuardedF32
pub const FRAC_1_PI: GuardedF32
1/π
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_2_PI: GuardedF32
pub const FRAC_2_PI: GuardedF32
2/π
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_2_SQRT_PI: GuardedF32
pub const FRAC_2_SQRT_PI: GuardedF32
1/√π
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const SQRT_2: GuardedF32
pub const SQRT_2: GuardedF32
√2
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const FRAC_1_SQRT_2: GuardedF32
pub const FRAC_1_SQRT_2: GuardedF32
1/√2
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const E: GuardedF32
pub const E: GuardedF32
Euler’s number (e)
See: std::f32::consts::E
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LOG2_E: GuardedF32
pub const LOG2_E: GuardedF32
log2(e)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LOG2_10: GuardedF32
pub const LOG2_10: GuardedF32
log2(10)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LOG10_2: GuardedF32
pub const LOG10_2: GuardedF32
log10(2)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LOG10_E: GuardedF32
pub const LOG10_E: GuardedF32
log10(e)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LN_2: GuardedF32
pub const LN_2: GuardedF32
ln(2)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const LN_10: GuardedF32
pub const LN_10: GuardedF32
ln(10)
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const fn check(self) -> Result<GuardedF32, FloatError>
pub const fn check(self) -> Result<GuardedF32, FloatError>
Checks if the UnguardedF32 value is valid (finite).
§Returns
Returns a GuardedF32 if the value is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{UnguardedF32, FloatError, GuardedF32};
let unchecked_f32 = UnguardedF32::new(1.0);
assert_eq!(unchecked_f32.check(), GuardedF32::new(1.0));
let invalid_f32 = UnguardedF32::new(f32::NAN);
assert_eq!(invalid_f32.check(), Err(FloatError::NaN));
let inf_f32 = UnguardedF32::new(f32::INFINITY);
assert_eq!(inf_f32.check(), Err(FloatError::Infinity));
let neg_inf_f32 = UnguardedF32::new(f32::NEG_INFINITY);
assert_eq!(neg_inf_f32.check(), Err(FloatError::Infinity));Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
Computes the absolute value of self. GuardedF32::abs returns a GuardedF32 type because
any value that is not NaN or infinite is guaranteed to return a valid value.
See: f32::abs
§Examples
use floatguard::{GuardedF32, UnguardedF32};
let checked = GuardedF32::new(3.5_f32).unwrap();
assert_eq!(checked.abs(), 3.5_f32);
let unchecked = UnguardedF32::new(-3.5_f32);
assert_eq!(unchecked.abs().check(), GuardedF32::new(3.5_f32));Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns a number that represents the sign of self. GuardedF32::signum returns a
GuardedF32 type because any value that is not NaN or infinite is guaranteed to return
a valid value.
See: f32::signum
§Examples
use floatguard::{GuardedF32, UnguardedF32};
let pos = GuardedF32::new(3.5_f32).unwrap();
let neg = UnguardedF32::new(-3.5_f32);
assert_eq!(pos.signum(), GuardedF32::new(1.0).unwrap());
assert_eq!(neg.signum().check(), GuardedF32::new(-1.0));Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn sqrt(self) -> UnguardedF32
pub fn sqrt(self) -> UnguardedF32
Returns the square root of self.
See: f32::sqrt
§Examples
use floatguard::{GuardedF32, FloatError, UnguardedF32};
let positive = GuardedF32::new(4.0_f32).unwrap();
let negative = GuardedF32::new(-4.0_f32).unwrap();
let negative_zero = UnguardedF32::new(-0.0_f32);
assert_eq!(positive.sqrt().check(), GuardedF32::new(2.0));
assert_eq!(negative.sqrt().check(), Err(FloatError::NaN));
assert_eq!(negative_zero.sqrt().check(), GuardedF32::new(-0.0));Source§impl UnguardedF32
impl UnguardedF32
Sourcepub const fn recip(self) -> UnguardedF32
pub const fn recip(self) -> UnguardedF32
Takes the reciprocal (inverse) of self, 1/x where x is self. This returns an
UncheckedF32 because CheckedF32::new(0.0).unwrap().recip() is invalid.
See: f32::recip
§Examples
use floatguard::{GuardedF32, UnguardedF32};
let x = UnguardedF32::new(2.0_f32);
let abs_difference = (x.recip() - (1.0 / x)).abs().check().unwrap();
assert!(abs_difference < GuardedF32::EPSILON);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn exp(self) -> UnguardedF32
pub fn exp(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn ln(self) -> UnguardedF32
pub fn ln(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn log2(self) -> UnguardedF32
pub fn log2(self) -> UnguardedF32
Returns the base-2 logarithm of a number, log2(self).
See: f32::log2
§Examples
use floatguard::UnguardedF32;
let two = UnguardedF32::new(2.0_f32);
let abs_difference = (two.log2() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);
let two = two.check().unwrap();
let abs_difference = (two.log2() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn log10(self) -> UnguardedF32
pub fn log10(self) -> UnguardedF32
Returns the base-10 logarithm of a number, log10(self).
See: f32::log10
§Examples
use floatguard::UnguardedF32;
let ten = UnguardedF32::new(10.0_f32);
let abs_difference = (ten.log10() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);
let ten = ten.check().unwrap();
let abs_difference = (ten.log10() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn log(self, base: impl Into<UnguardedF32>) -> UnguardedF32
pub fn log(self, base: impl Into<UnguardedF32>) -> UnguardedF32
Returns the logarithm of a number with a specified base, log(self, base).
See: f32::log
§Arguments
base - The base of the logarithm.
§Examples
use floatguard::UnguardedF32;
let two = UnguardedF32::new(2.0_f32);
let eight = UnguardedF32::new(8.0_f32);
// log(8, 2) == 3
let abs_difference = (eight.log(two) - 3.0).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn powi(self, power: i32) -> UnguardedF32
pub fn powi(self, power: i32) -> UnguardedF32
Raises a number to an integer power.
See: f32::powi
§Examples
use floatguard::{GuardedF32, UnguardedF32};
let x = UnguardedF32::new(2.0_f32);
let abs_difference = (x.powi(2) - (x * x)).abs().check().unwrap();
assert!(abs_difference <= GuardedF32::EPSILON);
assert!(UnguardedF32::new(f32::NAN).powi(2).check().is_err());Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn powf(self, power: impl Into<UnguardedF32>) -> UnguardedF32
pub fn powf(self, power: impl Into<UnguardedF32>) -> UnguardedF32
Raises a number to a floating-point power.
See: f32::powf
§Examples
use floatguard::{GuardedF32, UnguardedF32};
let x = UnguardedF32::new(2.0_f32);
let cubed = UnguardedF32::new(3.0);
let abs_difference = (x.powf(cubed) - (x * x * x)).abs().check().unwrap();
assert!(abs_difference <= GuardedF32::EPSILON);
let invalid = UnguardedF32::new(f32::NAN);
assert!(invalid.powf(x).check().is_err());Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn sin(self) -> UnguardedF32
pub fn sin(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn asin(self) -> UnguardedF32
pub fn asin(self) -> UnguardedF32
Computes the arcsine of a number. Return value is in radians in the range [-π/2, π/2] or invalid if the number is outside the range [-1, 1].
See: f32::asin
§Examples
use floatguard::GuardedF32;
let f = GuardedF32::FRAC_PI_2;
// asin(sin(pi/2))
let abs_difference = (f.sin().asin() - GuardedF32::FRAC_PI_2).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn sinh(self) -> UnguardedF32
pub fn sinh(self) -> UnguardedF32
Hyperbolic sine function.
See: f32::sinh
§Examples
use floatguard::GuardedF32;
let e = GuardedF32::E;
let x = 1.0_f32;
let f = x.sinh();
// Solving sinh() at 1 gives `(e^2-1)/(2e)`
let g = ((e * e) - 1.0) / (2.0 * e);
let abs_difference = (f - g).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn asinh(self) -> UnguardedF32
pub fn asinh(self) -> UnguardedF32
Inverse hyperbolic sine function.
See: f32::asinh
§Examples
use floatguard::UnguardedF32;
let x = UnguardedF32::new(1.0_f32);
let f = x.sinh().asinh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn cos(self) -> UnguardedF32
pub fn cos(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn acos(self) -> UnguardedF32
pub fn acos(self) -> UnguardedF32
Computes the arccosine of a number. Return value is in radians in the range [0, π], if the value is in the range [-1, 1].
See: f32::acos
§Examples
use floatguard::GuardedF32;
let f = GuardedF32::FRAC_PI_4;
// acos(cos(pi/4))
let abs_difference = (f.cos().acos() - GuardedF32::FRAC_PI_4).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn cosh(self) -> UnguardedF32
pub fn cosh(self) -> UnguardedF32
Hyperbolic cosine function.
See: f32::cosh
§Examples
use floatguard::UnguardedF32;
let e = UnguardedF32::E;
let x = UnguardedF32::new(1.0_f32);
let f = x.cosh();
// Solving cosh() at 1 gives this result
let g = ((e * e) + 1.0) / (2.0 * e);
let abs_difference = (f - g).abs().check().unwrap();
// Same result
assert!(abs_difference < 1.0e-6);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn acosh(self) -> UnguardedF32
pub fn acosh(self) -> UnguardedF32
Inverse hyperbolic cosine function.
See: f32::acosh
§Examples
use floatguard::UnguardedF32;
let x = UnguardedF32::new(1.0);
let f = x.cosh().acosh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1.0e-10);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn sin_cos(self) -> (UnguardedF32, UnguardedF32)
pub fn sin_cos(self) -> (UnguardedF32, UnguardedF32)
Simultaneously computes the sine and cosine of a number, x. Returns (sin(x), cos(x)).
See: f32::sin_cos
§Examples
use floatguard::GuardedF32;
let x = GuardedF32::FRAC_PI_4;
let f = x.sin_cos();
let abs_difference_0 = (f.0 - x.sin()).abs().check().unwrap();
let abs_difference_1 = (f.1 - x.cos()).abs().check().unwrap();
assert!(abs_difference_0 < 1.0e-7);
assert!(abs_difference_1 < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn tan(self) -> UnguardedF32
pub fn tan(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn atan(self) -> UnguardedF32
pub fn atan(self) -> UnguardedF32
Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn tanh(self) -> UnguardedF32
pub fn tanh(self) -> UnguardedF32
Computes the hyperbolic tangent of a number.
See: f32::tanh
§Examples
use floatguard::GuardedF32;
let x = GuardedF32::new(1.0_f32).unwrap();
let f = x.tanh();
// tanh(1) is approximately 0.7615941559557649
let abs_difference = (f - 0.7615941559557649).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn atanh(self) -> UnguardedF32
pub fn atanh(self) -> UnguardedF32
Computes the inverse hyperbolic tangent of a number. Return value is in the range (-∞, ∞) for inputs in the range (-1, 1).
See: f32::atanh
§Examples
use floatguard::UnguardedF32;
let x = UnguardedF32::new(0.5_f32);
let f = x.tanh().atanh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1.0e-7);Source§impl UnguardedF32
impl UnguardedF32
Sourcepub fn atan2(self, other: impl Into<UnguardedF32>) -> UnguardedF32
pub fn atan2(self, other: impl Into<UnguardedF32>) -> UnguardedF32
Computes the arctangent of self divided by other.
See: f32::atan2
§Arguments
other - The GuardedF32 value to divide self by.
§Returns
Returns a new GuardedF32 instance containing the result of the arctangent operation.
§Examples
use floatguard::UnguardedF32;
let a = UnguardedF32::new(1.0);
let b = UnguardedF32::new(2.0);
assert_eq!(f32::try_from(a.atan2(b)), Ok(0.4636476090008061)); // atan2(1.0, 2.0)
let invalid = UnguardedF32::new(f32::NAN);
assert!(invalid.atan2(a).check().is_err());Trait Implementations§
Source§impl Add<&GuardedF32> for &UnguardedF32
impl Add<&GuardedF32> for &UnguardedF32
Source§fn add(self, rhs: &GuardedF32) -> Self::Output
fn add(self, rhs: &GuardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&GuardedF32> for UnguardedF32
impl Add<&GuardedF32> for UnguardedF32
Source§fn add(self, rhs: &GuardedF32) -> Self::Output
fn add(self, rhs: &GuardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for &GuardedF32
impl Add<&UnguardedF32> for &GuardedF32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for &UnguardedF32
impl Add<&UnguardedF32> for &UnguardedF32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for &f32
impl Add<&UnguardedF32> for &f32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for GuardedF32
impl Add<&UnguardedF32> for GuardedF32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for UnguardedF32
impl Add<&UnguardedF32> for UnguardedF32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&UnguardedF32> for f32
impl Add<&UnguardedF32> for f32
Source§fn add(self, rhs: &UnguardedF32) -> Self::Output
fn add(self, rhs: &UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&f32> for &UnguardedF32
impl Add<&f32> for &UnguardedF32
Source§fn add(self, rhs: &f32) -> Self::Output
fn add(self, rhs: &f32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<&f32> for UnguardedF32
impl Add<&f32> for UnguardedF32
Source§fn add(self, rhs: &f32) -> Self::Output
fn add(self, rhs: &f32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<GuardedF32> for &UnguardedF32
impl Add<GuardedF32> for &UnguardedF32
Source§fn add(self, rhs: GuardedF32) -> Self::Output
fn add(self, rhs: GuardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<GuardedF32> for UnguardedF32
impl Add<GuardedF32> for UnguardedF32
Source§fn add(self, rhs: GuardedF32) -> Self::Output
fn add(self, rhs: GuardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<UnguardedF32> for &GuardedF32
impl Add<UnguardedF32> for &GuardedF32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<UnguardedF32> for &UnguardedF32
impl Add<UnguardedF32> for &UnguardedF32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<UnguardedF32> for &f32
impl Add<UnguardedF32> for &f32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<UnguardedF32> for GuardedF32
impl Add<UnguardedF32> for GuardedF32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<UnguardedF32> for f32
impl Add<UnguardedF32> for f32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<f32> for &UnguardedF32
impl Add<f32> for &UnguardedF32
Source§fn add(self, rhs: f32) -> Self::Output
fn add(self, rhs: f32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add<f32> for UnguardedF32
impl Add<f32> for UnguardedF32
Source§fn add(self, rhs: f32) -> Self::Output
fn add(self, rhs: f32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl Add for UnguardedF32
impl Add for UnguardedF32
Source§fn add(self, rhs: UnguardedF32) -> Self::Output
fn add(self, rhs: UnguardedF32) -> Self::Output
Adds two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
+ operator.Source§impl<T> AddAssign<T> for UnguardedF32where
T: Into<Self>,
impl<T> AddAssign<T> for UnguardedF32where
T: Into<Self>,
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Assigns the result of adding another UnguardedF32 to this one.
§Example
use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(1.0);
let b = UnguardedF32::from(2.0);
a += b;
assert_eq!(a.check(), GuardedF32::new(3.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(1.0);
let b = 2.0;
a += b;
assert_eq!(a.check(), GuardedF32::new(3.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(1.0);
let b = GuardedF32::new(2.0).unwrap();
a += b;
assert_eq!(a.check(), GuardedF32::new(3.0));Source§impl Clone for UnguardedF32
impl Clone for UnguardedF32
Source§fn clone(&self) -> UnguardedF32
fn clone(&self) -> UnguardedF32
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnguardedF32
impl Debug for UnguardedF32
Source§impl Default for UnguardedF32
impl Default for UnguardedF32
Source§fn default() -> UnguardedF32
fn default() -> UnguardedF32
Source§impl Display for UnguardedF32
impl Display for UnguardedF32
Source§impl Div<&GuardedF32> for &UnguardedF32
impl Div<&GuardedF32> for &UnguardedF32
Source§fn div(self, rhs: &GuardedF32) -> Self::Output
fn div(self, rhs: &GuardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&GuardedF32> for UnguardedF32
impl Div<&GuardedF32> for UnguardedF32
Source§fn div(self, rhs: &GuardedF32) -> Self::Output
fn div(self, rhs: &GuardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for &GuardedF32
impl Div<&UnguardedF32> for &GuardedF32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for &UnguardedF32
impl Div<&UnguardedF32> for &UnguardedF32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for &f32
impl Div<&UnguardedF32> for &f32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for GuardedF32
impl Div<&UnguardedF32> for GuardedF32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for UnguardedF32
impl Div<&UnguardedF32> for UnguardedF32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&UnguardedF32> for f32
impl Div<&UnguardedF32> for f32
Source§fn div(self, rhs: &UnguardedF32) -> Self::Output
fn div(self, rhs: &UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&f32> for &UnguardedF32
impl Div<&f32> for &UnguardedF32
Source§fn div(self, rhs: &f32) -> Self::Output
fn div(self, rhs: &f32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<&f32> for UnguardedF32
impl Div<&f32> for UnguardedF32
Source§fn div(self, rhs: &f32) -> Self::Output
fn div(self, rhs: &f32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<GuardedF32> for &UnguardedF32
impl Div<GuardedF32> for &UnguardedF32
Source§fn div(self, rhs: GuardedF32) -> Self::Output
fn div(self, rhs: GuardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<GuardedF32> for UnguardedF32
impl Div<GuardedF32> for UnguardedF32
Source§fn div(self, rhs: GuardedF32) -> Self::Output
fn div(self, rhs: GuardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<UnguardedF32> for &GuardedF32
impl Div<UnguardedF32> for &GuardedF32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<UnguardedF32> for &UnguardedF32
impl Div<UnguardedF32> for &UnguardedF32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<UnguardedF32> for &f32
impl Div<UnguardedF32> for &f32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<UnguardedF32> for GuardedF32
impl Div<UnguardedF32> for GuardedF32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<UnguardedF32> for f32
impl Div<UnguardedF32> for f32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<f32> for &UnguardedF32
impl Div<f32> for &UnguardedF32
Source§fn div(self, rhs: f32) -> Self::Output
fn div(self, rhs: f32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div<f32> for UnguardedF32
impl Div<f32> for UnguardedF32
Source§fn div(self, rhs: f32) -> Self::Output
fn div(self, rhs: f32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl Div for UnguardedF32
impl Div for UnguardedF32
Source§fn div(self, rhs: UnguardedF32) -> Self::Output
fn div(self, rhs: UnguardedF32) -> Self::Output
Divides one GuardedF32 value by another or a f32 by a GuardedF32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(6.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 / f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
/ operator.Source§impl<T> DivAssign<T> for UnguardedF32where
T: Into<Self>,
impl<T> DivAssign<T> for UnguardedF32where
T: Into<Self>,
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Assigns the result of dividing this UnguardedF32 by another.
§Example
use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(6.0);
let b = UnguardedF32::from(3.0);
a /= b;
assert_eq!(a.check(), GuardedF32::new(2.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(6.0);
let b = 3.0;
a /= b;
assert_eq!(a.check(), GuardedF32::new(2.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(6.0);
let b = GuardedF32::new(3.0).unwrap();
a /= b;
assert_eq!(a.check(), GuardedF32::new(2.0));Source§impl From<GuardedF32> for UnguardedF32
impl From<GuardedF32> for UnguardedF32
Source§fn from(value: GuardedF32) -> Self
fn from(value: GuardedF32) -> Self
Converts a GuardedF32 into an UnguardedF32.
§Returns
Returns a new UnguardedF32 instance containing the inner f32 value.
§Example
use floatguard::{UnguardedF32, GuardedF32};
let checked_f32 = GuardedF32::new(3.14).unwrap();
let unchecked_f32 = UnguardedF32::from(checked_f32);
assert_eq!(unchecked_f32.check(), GuardedF32::new(3.14));Source§impl From<f32> for UnguardedF32
impl From<f32> for UnguardedF32
Source§fn from(value: f32) -> Self
fn from(value: f32) -> Self
Converts an f32 into a GuardedF32.
§Returns
Returns a GuardedF32 if the value is valid (finite), otherwise returns an error.
§Example
use floatguard::{UnguardedF32, GuardedF32, FloatError};
assert_eq!(UnguardedF32::from(3.14).check(), GuardedF32::new(3.14));
assert_eq!(UnguardedF32::from(f32::NAN).check(), Err(FloatError::NaN));Source§impl Mul<&GuardedF32> for &UnguardedF32
impl Mul<&GuardedF32> for &UnguardedF32
Source§fn mul(self, rhs: &GuardedF32) -> Self::Output
fn mul(self, rhs: &GuardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&GuardedF32> for UnguardedF32
impl Mul<&GuardedF32> for UnguardedF32
Source§fn mul(self, rhs: &GuardedF32) -> Self::Output
fn mul(self, rhs: &GuardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for &GuardedF32
impl Mul<&UnguardedF32> for &GuardedF32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for &UnguardedF32
impl Mul<&UnguardedF32> for &UnguardedF32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for &f32
impl Mul<&UnguardedF32> for &f32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for GuardedF32
impl Mul<&UnguardedF32> for GuardedF32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for UnguardedF32
impl Mul<&UnguardedF32> for UnguardedF32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&UnguardedF32> for f32
impl Mul<&UnguardedF32> for f32
Source§fn mul(self, rhs: &UnguardedF32) -> Self::Output
fn mul(self, rhs: &UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&f32> for &UnguardedF32
impl Mul<&f32> for &UnguardedF32
Source§fn mul(self, rhs: &f32) -> Self::Output
fn mul(self, rhs: &f32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<&f32> for UnguardedF32
impl Mul<&f32> for UnguardedF32
Source§fn mul(self, rhs: &f32) -> Self::Output
fn mul(self, rhs: &f32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<GuardedF32> for &UnguardedF32
impl Mul<GuardedF32> for &UnguardedF32
Source§fn mul(self, rhs: GuardedF32) -> Self::Output
fn mul(self, rhs: GuardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<GuardedF32> for UnguardedF32
impl Mul<GuardedF32> for UnguardedF32
Source§fn mul(self, rhs: GuardedF32) -> Self::Output
fn mul(self, rhs: GuardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<UnguardedF32> for &GuardedF32
impl Mul<UnguardedF32> for &GuardedF32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<UnguardedF32> for &UnguardedF32
impl Mul<UnguardedF32> for &UnguardedF32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<UnguardedF32> for &f32
impl Mul<UnguardedF32> for &f32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<UnguardedF32> for GuardedF32
impl Mul<UnguardedF32> for GuardedF32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<UnguardedF32> for f32
impl Mul<UnguardedF32> for f32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<f32> for &UnguardedF32
impl Mul<f32> for &UnguardedF32
Source§fn mul(self, rhs: f32) -> Self::Output
fn mul(self, rhs: f32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul<f32> for UnguardedF32
impl Mul<f32> for UnguardedF32
Source§fn mul(self, rhs: f32) -> Self::Output
fn mul(self, rhs: f32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl Mul for UnguardedF32
impl Mul for UnguardedF32
Source§fn mul(self, rhs: UnguardedF32) -> Self::Output
fn mul(self, rhs: UnguardedF32) -> Self::Output
Multiplies two GuardedF32 values or a GuardedF32 and a f32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(2.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
* operator.Source§impl<T> MulAssign<T> for UnguardedF32where
T: Into<Self>,
impl<T> MulAssign<T> for UnguardedF32where
T: Into<Self>,
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Assigns the result of multiplying this UnguardedF32 by another.
§Example
use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(2.0);
let b = UnguardedF32::from(3.0);
a *= b;
assert_eq!(a.check(), GuardedF32::new(6.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(2.0);
let b = 3.0;
a *= b;
assert_eq!(a.check(), GuardedF32::new(6.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(2.0);
let b = GuardedF32::new(3.0).unwrap();
a *= b;
assert_eq!(a.check(), GuardedF32::new(6.0));Source§impl Neg for &UnguardedF32
impl Neg for &UnguardedF32
Source§fn neg(self) -> Self::Output
fn neg(self) -> Self::Output
Negates the GuardedF32 or UnguardedF32 value.
§Returns
Returns a new Self instance with the negated value. Unlike other operations, this does not
default to creating an UnguardedF32 for GuardedF32, as -x is always valid for finite
and non-NaN values.
§Example
use floatguard::{GuardedF32, FloatError, UnguardedF32};
let value = GuardedF32::new(2.0).unwrap();
assert_eq!(-value, -2.0);
let value = UnguardedF32::new(2.0);
assert_eq!(f32::try_from(-value), Ok(-2.0));
let invalid_value = UnguardedF32::new(f32::NAN);
assert_eq!((-invalid_value).check(), Err(FloatError::NaN));
let infinity_value = UnguardedF32::new(f32::INFINITY);
assert_eq!((-infinity_value).check(), Err(FloatError::Infinity));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Neg for UnguardedF32
impl Neg for UnguardedF32
Source§fn neg(self) -> Self::Output
fn neg(self) -> Self::Output
Negates the GuardedF32 or UnguardedF32 value.
§Returns
Returns a new Self instance with the negated value. Unlike other operations, this does not
default to creating an UnguardedF32 for GuardedF32, as -x is always valid for finite
and non-NaN values.
§Example
use floatguard::{GuardedF32, FloatError, UnguardedF32};
let value = GuardedF32::new(2.0).unwrap();
assert_eq!(-value, -2.0);
let value = UnguardedF32::new(2.0);
assert_eq!(f32::try_from(-value), Ok(-2.0));
let invalid_value = UnguardedF32::new(f32::NAN);
assert_eq!((-invalid_value).check(), Err(FloatError::NaN));
let infinity_value = UnguardedF32::new(f32::INFINITY);
assert_eq!((-infinity_value).check(), Err(FloatError::Infinity));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Rem<&GuardedF32> for &UnguardedF32
impl Rem<&GuardedF32> for &UnguardedF32
Source§fn rem(self, rhs: &GuardedF32) -> Self::Output
fn rem(self, rhs: &GuardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&GuardedF32> for UnguardedF32
impl Rem<&GuardedF32> for UnguardedF32
Source§fn rem(self, rhs: &GuardedF32) -> Self::Output
fn rem(self, rhs: &GuardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for &GuardedF32
impl Rem<&UnguardedF32> for &GuardedF32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for &UnguardedF32
impl Rem<&UnguardedF32> for &UnguardedF32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for &f32
impl Rem<&UnguardedF32> for &f32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for GuardedF32
impl Rem<&UnguardedF32> for GuardedF32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for UnguardedF32
impl Rem<&UnguardedF32> for UnguardedF32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&UnguardedF32> for f32
impl Rem<&UnguardedF32> for f32
Source§fn rem(self, rhs: &UnguardedF32) -> Self::Output
fn rem(self, rhs: &UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&f32> for &UnguardedF32
impl Rem<&f32> for &UnguardedF32
Source§fn rem(self, rhs: &f32) -> Self::Output
fn rem(self, rhs: &f32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<&f32> for UnguardedF32
impl Rem<&f32> for UnguardedF32
Source§fn rem(self, rhs: &f32) -> Self::Output
fn rem(self, rhs: &f32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<GuardedF32> for &UnguardedF32
impl Rem<GuardedF32> for &UnguardedF32
Source§fn rem(self, rhs: GuardedF32) -> Self::Output
fn rem(self, rhs: GuardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<GuardedF32> for UnguardedF32
impl Rem<GuardedF32> for UnguardedF32
Source§fn rem(self, rhs: GuardedF32) -> Self::Output
fn rem(self, rhs: GuardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<UnguardedF32> for &GuardedF32
impl Rem<UnguardedF32> for &GuardedF32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<UnguardedF32> for &UnguardedF32
impl Rem<UnguardedF32> for &UnguardedF32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<UnguardedF32> for &f32
impl Rem<UnguardedF32> for &f32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<UnguardedF32> for GuardedF32
impl Rem<UnguardedF32> for GuardedF32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<UnguardedF32> for f32
impl Rem<UnguardedF32> for f32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<f32> for &UnguardedF32
impl Rem<f32> for &UnguardedF32
Source§fn rem(self, rhs: f32) -> Self::Output
fn rem(self, rhs: f32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem<f32> for UnguardedF32
impl Rem<f32> for UnguardedF32
Source§fn rem(self, rhs: f32) -> Self::Output
fn rem(self, rhs: f32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl Rem for UnguardedF32
impl Rem for UnguardedF32
Source§fn rem(self, rhs: UnguardedF32) -> Self::Output
fn rem(self, rhs: UnguardedF32) -> Self::Output
Computes the remainder of division between two GuardedF32 values or a GuardedF32 and
a f32.
§Example
use floatguard::{GuardedF32, UnguardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((value1 % f32::NAN).check(), Err(FloatError::NaN));
assert_eq!((f32::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF32::new(6.0);
assert_eq!((f32::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f32::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF32::new(f32::INFINITY);
let value2 = UnguardedF32::new(f32::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
% operator.Source§impl<T> RemAssign<T> for UnguardedF32where
T: Into<Self>,
impl<T> RemAssign<T> for UnguardedF32where
T: Into<Self>,
Source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
Assigns the result of taking the remainder of this UnguardedF32 divided by another.
§Example
use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(5.0);
let b = UnguardedF32::from(2.0);
a %= b;
assert_eq!(a.check(), GuardedF32::new(1.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(5.0);
let b = 2.0;
a %= b;
assert_eq!(a.check(), GuardedF32::new(1.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(5.0);
let b = GuardedF32::new(2.0).unwrap();
a %= b;
assert_eq!(a.check(), GuardedF32::new(1.0));Source§impl Sub<&GuardedF32> for &UnguardedF32
impl Sub<&GuardedF32> for &UnguardedF32
Source§fn sub(self, rhs: &GuardedF32) -> Self::Output
fn sub(self, rhs: &GuardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&GuardedF32> for UnguardedF32
impl Sub<&GuardedF32> for UnguardedF32
Source§fn sub(self, rhs: &GuardedF32) -> Self::Output
fn sub(self, rhs: &GuardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for &GuardedF32
impl Sub<&UnguardedF32> for &GuardedF32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for &UnguardedF32
impl Sub<&UnguardedF32> for &UnguardedF32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for &f32
impl Sub<&UnguardedF32> for &f32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for GuardedF32
impl Sub<&UnguardedF32> for GuardedF32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for UnguardedF32
impl Sub<&UnguardedF32> for UnguardedF32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&UnguardedF32> for f32
impl Sub<&UnguardedF32> for f32
Source§fn sub(self, rhs: &UnguardedF32) -> Self::Output
fn sub(self, rhs: &UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&f32> for &UnguardedF32
impl Sub<&f32> for &UnguardedF32
Source§fn sub(self, rhs: &f32) -> Self::Output
fn sub(self, rhs: &f32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<&f32> for UnguardedF32
impl Sub<&f32> for UnguardedF32
Source§fn sub(self, rhs: &f32) -> Self::Output
fn sub(self, rhs: &f32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<GuardedF32> for &UnguardedF32
impl Sub<GuardedF32> for &UnguardedF32
Source§fn sub(self, rhs: GuardedF32) -> Self::Output
fn sub(self, rhs: GuardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<GuardedF32> for UnguardedF32
impl Sub<GuardedF32> for UnguardedF32
Source§fn sub(self, rhs: GuardedF32) -> Self::Output
fn sub(self, rhs: GuardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<UnguardedF32> for &GuardedF32
impl Sub<UnguardedF32> for &GuardedF32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<UnguardedF32> for &UnguardedF32
impl Sub<UnguardedF32> for &UnguardedF32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<UnguardedF32> for &f32
impl Sub<UnguardedF32> for &f32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<UnguardedF32> for GuardedF32
impl Sub<UnguardedF32> for GuardedF32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<UnguardedF32> for f32
impl Sub<UnguardedF32> for f32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<f32> for &UnguardedF32
impl Sub<f32> for &UnguardedF32
Source§fn sub(self, rhs: f32) -> Self::Output
fn sub(self, rhs: f32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub<f32> for UnguardedF32
impl Sub<f32> for UnguardedF32
Source§fn sub(self, rhs: f32) -> Self::Output
fn sub(self, rhs: f32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl Sub for UnguardedF32
impl Sub for UnguardedF32
Source§fn sub(self, rhs: UnguardedF32) -> Self::Output
fn sub(self, rhs: UnguardedF32) -> Self::Output
Subtracts one GuardedF32 value from another or a f32 from a GuardedF32.
§Example
use floatguard::{GuardedF32, FloatError};
let value1 = GuardedF32::new(5.0).unwrap();
let value2 = GuardedF32::new(3.0).unwrap();
assert_eq!(f32::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f32::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF32
type Output = UnguardedF32
- operator.Source§impl<T> SubAssign<T> for UnguardedF32where
T: Into<Self>,
impl<T> SubAssign<T> for UnguardedF32where
T: Into<Self>,
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Assigns the result of subtracting another UnguardedF32 from this one.
§Example
use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(3.0);
let b = UnguardedF32::from(2.0);
a -= b;
assert_eq!(a.check(), GuardedF32::new(1.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(3.0);
let b = 2.0;
a -= b;
assert_eq!(a.check(), GuardedF32::new(1.0));use floatguard::{GuardedF32, UnguardedF32};
let mut a = UnguardedF32::from(3.0);
let b = GuardedF32::new(2.0).unwrap();
a -= b;
assert_eq!(a.check(), GuardedF32::new(1.0));Source§impl TryFrom<UnguardedF32> for GuardedF32
impl TryFrom<UnguardedF32> for GuardedF32
Source§fn try_from(value: UnguardedF32) -> Result<Self, Self::Error>
fn try_from(value: UnguardedF32) -> Result<Self, Self::Error>
Converts an UnguardedF32 to GuardedF32.
§Returns
Returns a GuardedF32 if the value is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{UnguardedF32, FloatError, GuardedF32};
let valid_value = UnguardedF32::new(2.0);
assert_eq!(valid_value.try_into(), GuardedF32::new(2.0));
let invalid_value = UnguardedF32::new(f32::NAN);
assert_eq!(GuardedF32::try_from(invalid_value), Err(FloatError::NaN));
let inf_value = UnguardedF32::new(f32::INFINITY);
assert_eq!(GuardedF32::try_from(inf_value), Err(FloatError::Infinity));Source§impl TryFrom<UnguardedF32> for f32
Implementing the ability to convert GuardedF32 to f32 safely.
impl TryFrom<UnguardedF32> for f32
Implementing the ability to convert GuardedF32 to f32 safely.
This conversion will return an error if the value is NaN or infinite.
Source§fn try_from(value: UnguardedF32) -> Result<Self, Self::Error>
fn try_from(value: UnguardedF32) -> Result<Self, Self::Error>
Converts a GuardedF32 to f32.
§Returns
Returns the inner f32 value if it is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{UnguardedF32, FloatError};
let valid_value = UnguardedF32::new(2.0);
assert_eq!(valid_value.try_into(), Ok(2.0));
let invalid_value = UnguardedF32::new(f32::NAN);
assert_eq!(f32::try_from(invalid_value), Err(FloatError::NaN));
let inf_value = UnguardedF32::new(f32::INFINITY);
assert_eq!(f32::try_from(inf_value), Err(FloatError::Infinity));