pub struct GuardedF64(/* private fields */);Expand description
Represents a checked floating-point number that ensures it is neither NaN nor infinite.
§Example
use floatguard::{GuardedF64, FloatError};
let checked_f64 = GuardedF64::new(1.0).expect("1.0 is a valid f64 value");
assert_eq!((checked_f64 + 1.0).check(), GuardedF64::new(2.0));
assert_eq!((checked_f64 / 0.0).check(), Err(FloatError::Infinity));
assert_eq!((checked_f64 - f64::INFINITY).check(), Err(FloatError::Infinity));
assert_eq!((checked_f64 % f64::NAN).check(), Err(FloatError::NaN));Implementations§
Source§impl GuardedF64
impl GuardedF64
Sourcepub const RADIX: u32 = 2u32
pub const RADIX: u32 = 2u32
The radix or base of the internal representation of f64.
See: f64::RADIX
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MANTISSA_DIGITS: u32 = 53u32
pub const MANTISSA_DIGITS: u32 = 53u32
Number of significant digits in base 2.
See: f64::MANTISSA_DIGITS.
Source§impl GuardedF64
impl GuardedF64
Sourcepub const DIGITS: u32 = 15u32
pub const DIGITS: u32 = 15u32
Approximate number of significant digits in base 10.
See: f64::DIGITS.
Source§impl GuardedF64
impl GuardedF64
Sourcepub const EPSILON: GuardedF64
pub const EPSILON: GuardedF64
The difference between 1.0 and the next larger representable number. Equal to
21 − MANTISSA_DIGITS.
See: f64::EPSILON
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MIN: GuardedF64
pub const MIN: GuardedF64
Smallest finite f64 value.
See: f64::MIN
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MIN_POSITIVE: GuardedF64
pub const MIN_POSITIVE: GuardedF64
Smallest positive normal f64 value.
See: f64::MIN_POSITIVE
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MAX: GuardedF64
pub const MAX: GuardedF64
Largest finite f64 value.
See: f64::MAX
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MIN_EXP: i32 = -1_021i32
pub const MIN_EXP: i32 = -1_021i32
Minimum possible normal power of 2 exponent.
See: f64::MIN_EXP
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MAX_EXP: i32 = 1_024i32
pub const MAX_EXP: i32 = 1_024i32
Maximum possible normal power of 2 exponent.
See: f64::MAX_EXP
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MIN_10_EXP: i32 = -307i32
pub const MIN_10_EXP: i32 = -307i32
Minimum possible normal power of 10 exponent.
See: f64::MIN_10_EXP
Source§impl GuardedF64
impl GuardedF64
Sourcepub const MAX_10_EXP: i32 = 308i32
pub const MAX_10_EXP: i32 = 308i32
Maximum possible normal power of 10 exponent.
See: f64::MAX_10_EXP
Source§impl GuardedF64
impl GuardedF64
Sourcepub const PI: GuardedF64
pub const PI: GuardedF64
Archimedes’ constant (π)
See: std::f64::consts::PI
Source§impl GuardedF64
impl GuardedF64
Sourcepub const TAU: GuardedF64
pub const TAU: GuardedF64
The full circle constant (τ = 2π)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_PI_2: GuardedF64
pub const FRAC_PI_2: GuardedF64
π/2
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_PI_3: GuardedF64
pub const FRAC_PI_3: GuardedF64
π/3
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_PI_4: GuardedF64
pub const FRAC_PI_4: GuardedF64
π/4
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_PI_6: GuardedF64
pub const FRAC_PI_6: GuardedF64
π/6
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_PI_8: GuardedF64
pub const FRAC_PI_8: GuardedF64
π/8
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_1_PI: GuardedF64
pub const FRAC_1_PI: GuardedF64
1/π
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_2_PI: GuardedF64
pub const FRAC_2_PI: GuardedF64
2/π
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_2_SQRT_PI: GuardedF64
pub const FRAC_2_SQRT_PI: GuardedF64
1/√π
Source§impl GuardedF64
impl GuardedF64
Sourcepub const SQRT_2: GuardedF64
pub const SQRT_2: GuardedF64
√2
Source§impl GuardedF64
impl GuardedF64
Sourcepub const FRAC_1_SQRT_2: GuardedF64
pub const FRAC_1_SQRT_2: GuardedF64
1/√2
Source§impl GuardedF64
impl GuardedF64
Sourcepub const E: GuardedF64
pub const E: GuardedF64
Euler’s number (e)
See: std::f64::consts::E
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LOG2_E: GuardedF64
pub const LOG2_E: GuardedF64
log2(e)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LOG2_10: GuardedF64
pub const LOG2_10: GuardedF64
log2(10)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LOG10_2: GuardedF64
pub const LOG10_2: GuardedF64
log10(2)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LOG10_E: GuardedF64
pub const LOG10_E: GuardedF64
log10(e)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LN_2: GuardedF64
pub const LN_2: GuardedF64
ln(2)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const LN_10: GuardedF64
pub const LN_10: GuardedF64
ln(10)
Source§impl GuardedF64
impl GuardedF64
Sourcepub const fn new(value: f64) -> Result<Self, FloatError>
pub const fn new(value: f64) -> Result<Self, FloatError>
Creates a new GuardedF64 instance.
§Returns
Returns a new GuardedF64 instance containing the provided f64 value if it is valid (finite).
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{GuardedF64, FloatError};
let valid_value = GuardedF64::new(2.0).unwrap();
assert_eq!(valid_value, 2.0f64);
let invalid_value = GuardedF64::new(f64::NAN);
assert_eq!(invalid_value, Err(FloatError::NaN));
let inf_value = GuardedF64::new(f64::INFINITY);
assert_eq!(inf_value, Err(FloatError::Infinity));Source§impl GuardedF64
impl GuardedF64
Sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
Computes the absolute value of self. GuardedF64::abs returns a GuardedF64 type because
any value that is not NaN or infinite is guaranteed to return a valid value.
See: f64::abs
§Examples
use floatguard::{GuardedF64, UnguardedF64};
let checked = GuardedF64::new(3.5_f64).unwrap();
assert_eq!(checked.abs(), 3.5_f64);
let unchecked = UnguardedF64::new(-3.5_f64);
assert_eq!(unchecked.abs().check(), GuardedF64::new(3.5_f64));Source§impl GuardedF64
impl GuardedF64
Sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns a number that represents the sign of self. GuardedF64::signum returns a
GuardedF64 type because any value that is not NaN or infinite is guaranteed to return
a valid value.
See: f64::signum
§Examples
use floatguard::{GuardedF64, UnguardedF64};
let pos = GuardedF64::new(3.5_f64).unwrap();
let neg = UnguardedF64::new(-3.5_f64);
assert_eq!(pos.signum(), GuardedF64::new(1.0).unwrap());
assert_eq!(neg.signum().check(), GuardedF64::new(-1.0));Source§impl GuardedF64
impl GuardedF64
Sourcepub fn sqrt(self) -> UnguardedF64
pub fn sqrt(self) -> UnguardedF64
Returns the square root of self.
See: f64::sqrt
§Examples
use floatguard::{GuardedF64, FloatError, UnguardedF64};
let positive = GuardedF64::new(4.0_f64).unwrap();
let negative = GuardedF64::new(-4.0_f64).unwrap();
let negative_zero = UnguardedF64::new(-0.0_f64);
assert_eq!(positive.sqrt().check(), GuardedF64::new(2.0));
assert_eq!(negative.sqrt().check(), Err(FloatError::NaN));
assert_eq!(negative_zero.sqrt().check(), GuardedF64::new(-0.0));Source§impl GuardedF64
impl GuardedF64
Sourcepub const fn recip(self) -> UnguardedF64
pub const fn recip(self) -> UnguardedF64
Takes the reciprocal (inverse) of self, 1/x where x is self. This returns an
UncheckedF64 because CheckedF64::new(0.0).unwrap().recip() is invalid.
See: f64::recip
§Examples
use floatguard::{GuardedF64, UnguardedF64};
let x = UnguardedF64::new(2.0_f64);
let abs_difference = (x.recip() - (1.0 / x)).abs().check().unwrap();
assert!(abs_difference < GuardedF64::EPSILON);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn exp(self) -> UnguardedF64
pub fn exp(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn ln(self) -> UnguardedF64
pub fn ln(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn log2(self) -> UnguardedF64
pub fn log2(self) -> UnguardedF64
Returns the base-2 logarithm of a number, log2(self).
See: f64::log2
§Examples
use floatguard::UnguardedF64;
let two = UnguardedF64::new(2.0_f64);
let abs_difference = (two.log2() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1e-10);
let two = two.check().unwrap();
let abs_difference = (two.log2() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn log10(self) -> UnguardedF64
pub fn log10(self) -> UnguardedF64
Returns the base-10 logarithm of a number, log10(self).
See: f64::log10
§Examples
use floatguard::UnguardedF64;
let ten = UnguardedF64::new(10.0_f64);
let abs_difference = (ten.log10() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1e-10);
let ten = ten.check().unwrap();
let abs_difference = (ten.log10() - 1.0).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn log(self, base: impl Into<UnguardedF64>) -> UnguardedF64
pub fn log(self, base: impl Into<UnguardedF64>) -> UnguardedF64
Returns the logarithm of a number with a specified base, log(self, base).
See: f64::log
§Arguments
base - The base of the logarithm.
§Examples
use floatguard::UnguardedF64;
let two = UnguardedF64::new(2.0_f64);
let eight = UnguardedF64::new(8.0_f64);
// log(8, 2) == 3
let abs_difference = (eight.log(two) - 3.0).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn powi(self, power: i32) -> UnguardedF64
pub fn powi(self, power: i32) -> UnguardedF64
Raises a number to an integer power.
See: f64::powi
§Examples
use floatguard::{GuardedF64, UnguardedF64};
let x = UnguardedF64::new(2.0_f64);
let abs_difference = (x.powi(2) - (x * x)).abs().check().unwrap();
assert!(abs_difference <= GuardedF64::EPSILON);
assert!(UnguardedF64::new(f64::NAN).powi(2).check().is_err());Source§impl GuardedF64
impl GuardedF64
Sourcepub fn powf(self, power: impl Into<UnguardedF64>) -> UnguardedF64
pub fn powf(self, power: impl Into<UnguardedF64>) -> UnguardedF64
Raises a number to a floating-point power.
See: f64::powf
§Examples
use floatguard::{GuardedF64, UnguardedF64};
let x = UnguardedF64::new(2.0_f64);
let cubed = UnguardedF64::new(3.0);
let abs_difference = (x.powf(cubed) - (x * x * x)).abs().check().unwrap();
assert!(abs_difference <= GuardedF64::EPSILON);
let invalid = UnguardedF64::new(f64::NAN);
assert!(invalid.powf(x).check().is_err());Source§impl GuardedF64
impl GuardedF64
Sourcepub fn sin(self) -> UnguardedF64
pub fn sin(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn asin(self) -> UnguardedF64
pub fn asin(self) -> UnguardedF64
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: f64::asin
§Examples
use floatguard::GuardedF64;
let f = GuardedF64::FRAC_PI_2;
// asin(sin(pi/2))
let abs_difference = (f.sin().asin() - GuardedF64::FRAC_PI_2).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn sinh(self) -> UnguardedF64
pub fn sinh(self) -> UnguardedF64
Hyperbolic sine function.
See: f64::sinh
§Examples
use floatguard::GuardedF64;
let e = GuardedF64::E;
let x = 1.0_f64;
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 < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn asinh(self) -> UnguardedF64
pub fn asinh(self) -> UnguardedF64
Inverse hyperbolic sine function.
See: f64::asinh
§Examples
use floatguard::UnguardedF64;
let x = UnguardedF64::new(1.0_f64);
let f = x.sinh().asinh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1.0e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn cos(self) -> UnguardedF64
pub fn cos(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn acos(self) -> UnguardedF64
pub fn acos(self) -> UnguardedF64
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: f64::acos
§Examples
use floatguard::GuardedF64;
let f = GuardedF64::FRAC_PI_4;
// acos(cos(pi/4))
let abs_difference = (f.cos().acos() - GuardedF64::FRAC_PI_4).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn cosh(self) -> UnguardedF64
pub fn cosh(self) -> UnguardedF64
Hyperbolic cosine function.
See: f64::cosh
§Examples
use floatguard::UnguardedF64;
let e = UnguardedF64::E;
let x = UnguardedF64::new(1.0_f64);
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 < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn acosh(self) -> UnguardedF64
pub fn acosh(self) -> UnguardedF64
Inverse hyperbolic cosine function.
See: f64::acosh
§Examples
use floatguard::UnguardedF64;
let x = UnguardedF64::new(1.0);
let f = x.cosh().acosh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1.0e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn sin_cos(self) -> (UnguardedF64, UnguardedF64)
pub fn sin_cos(self) -> (UnguardedF64, UnguardedF64)
Simultaneously computes the sine and cosine of a number, x. Returns (sin(x), cos(x)).
See: f64::sin_cos
§Examples
use floatguard::GuardedF64;
let x = GuardedF64::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 < 1e-10);
assert!(abs_difference_1 < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn tan(self) -> UnguardedF64
pub fn tan(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn atan(self) -> UnguardedF64
pub fn atan(self) -> UnguardedF64
Source§impl GuardedF64
impl GuardedF64
Sourcepub fn tanh(self) -> UnguardedF64
pub fn tanh(self) -> UnguardedF64
Computes the hyperbolic tangent of a number.
See: f64::tanh
§Examples
use floatguard::GuardedF64;
let x = GuardedF64::new(1.0_f64).unwrap();
let f = x.tanh();
// tanh(1) is approximately 0.7615941559557649
let abs_difference = (f - 0.7615941559557649).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn atanh(self) -> UnguardedF64
pub fn atanh(self) -> UnguardedF64
Computes the inverse hyperbolic tangent of a number. Return value is in the range (-∞, ∞) for inputs in the range (-1, 1).
See: f64::atanh
§Examples
use floatguard::UnguardedF64;
let x = UnguardedF64::new(0.5_f64);
let f = x.tanh().atanh();
let abs_difference = (f - x).abs().check().unwrap();
assert!(abs_difference < 1e-10);Source§impl GuardedF64
impl GuardedF64
Sourcepub fn atan2(self, other: impl Into<UnguardedF64>) -> UnguardedF64
pub fn atan2(self, other: impl Into<UnguardedF64>) -> UnguardedF64
Computes the arctangent of self divided by other.
See: f64::atan2
§Arguments
other - The GuardedF64 value to divide self by.
§Returns
Returns a new GuardedF64 instance containing the result of the arctangent operation.
§Examples
use floatguard::UnguardedF64;
let a = UnguardedF64::new(1.0);
let b = UnguardedF64::new(2.0);
assert_eq!(f64::try_from(a.atan2(b)), Ok(0.4636476090008061)); // atan2(1.0, 2.0)
let invalid = UnguardedF64::new(f64::NAN);
assert!(invalid.atan2(a).check().is_err());Methods from Deref<Target = f64>§
pub const RADIX: u32 = 2u32
pub const MANTISSA_DIGITS: u32 = 53u32
pub const DIGITS: u32 = 15u32
pub const EPSILON: f64 = 2.2204460492503131E-16f64
pub const MIN: f64 = -1.7976931348623157E+308f64
pub const MIN_POSITIVE: f64 = 2.2250738585072014E-308f64
pub const MAX: f64 = 1.7976931348623157E+308f64
pub const MIN_EXP: i32 = -1_021i32
pub const MAX_EXP: i32 = 1_024i32
pub const MIN_10_EXP: i32 = -307i32
pub const MAX_10_EXP: i32 = 308i32
pub const NAN: f64 = NaN_f64
pub const INFINITY: f64 = +Inf_f64
pub const NEG_INFINITY: f64 = -Inf_f64
1.62.0 · Sourcepub fn total_cmp(&self, other: &f64) -> Ordering
pub fn total_cmp(&self, other: &f64) -> Ordering
Returns the ordering between self and other.
Unlike the standard partial comparison between floating point numbers,
this comparison always produces an ordering in accordance to
the totalOrder predicate as defined in the IEEE 754 (2008 revision)
floating point standard. The values are ordered in the following sequence:
- negative quiet NaN
- negative signaling NaN
- negative infinity
- negative numbers
- negative subnormal numbers
- negative zero
- positive zero
- positive subnormal numbers
- positive numbers
- positive infinity
- positive signaling NaN
- positive quiet NaN.
The ordering established by this function does not always agree with the
PartialOrd and PartialEq implementations of f64. For example,
they consider negative and positive zero equal, while total_cmp
doesn’t.
The interpretation of the signaling NaN bit follows the definition in the IEEE 754 standard, which may not match the interpretation by some of the older, non-conformant (e.g. MIPS) hardware implementations.
§Example
struct GoodBoy {
name: String,
weight: f64,
}
let mut bois = vec![
GoodBoy { name: "Pucci".to_owned(), weight: 0.1 },
GoodBoy { name: "Woofer".to_owned(), weight: 99.0 },
GoodBoy { name: "Yapper".to_owned(), weight: 10.0 },
GoodBoy { name: "Chonk".to_owned(), weight: f64::INFINITY },
GoodBoy { name: "Abs. Unit".to_owned(), weight: f64::NAN },
GoodBoy { name: "Floaty".to_owned(), weight: -5.0 },
];
bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
// `f64::NAN` could be positive or negative, which will affect the sort order.
if f64::NAN.is_sign_negative() {
assert!(bois.into_iter().map(|b| b.weight)
.zip([f64::NAN, -5.0, 0.1, 10.0, 99.0, f64::INFINITY].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
} else {
assert!(bois.into_iter().map(|b| b.weight)
.zip([-5.0, 0.1, 10.0, 99.0, f64::INFINITY, f64::NAN].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
}Trait Implementations§
Source§impl Add<&GuardedF64> for &GuardedF64
impl Add<&GuardedF64> for &GuardedF64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&GuardedF64> for &UnguardedF64
impl Add<&GuardedF64> for &UnguardedF64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&GuardedF64> for &f64
impl Add<&GuardedF64> for &f64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&GuardedF64> for GuardedF64
impl Add<&GuardedF64> for GuardedF64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&GuardedF64> for UnguardedF64
impl Add<&GuardedF64> for UnguardedF64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&GuardedF64> for f64
impl Add<&GuardedF64> for f64
Source§fn add(self, rhs: &GuardedF64) -> Self::Output
fn add(self, rhs: &GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&UnguardedF64> for &GuardedF64
impl Add<&UnguardedF64> for &GuardedF64
Source§fn add(self, rhs: &UnguardedF64) -> Self::Output
fn add(self, rhs: &UnguardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&UnguardedF64> for GuardedF64
impl Add<&UnguardedF64> for GuardedF64
Source§fn add(self, rhs: &UnguardedF64) -> Self::Output
fn add(self, rhs: &UnguardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&f64> for &GuardedF64
impl Add<&f64> for &GuardedF64
Source§fn add(self, rhs: &f64) -> Self::Output
fn add(self, rhs: &f64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<&f64> for GuardedF64
impl Add<&f64> for GuardedF64
Source§fn add(self, rhs: &f64) -> Self::Output
fn add(self, rhs: &f64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<GuardedF64> for &GuardedF64
impl Add<GuardedF64> for &GuardedF64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<GuardedF64> for &UnguardedF64
impl Add<GuardedF64> for &UnguardedF64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<GuardedF64> for &f64
impl Add<GuardedF64> for &f64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<GuardedF64> for UnguardedF64
impl Add<GuardedF64> for UnguardedF64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<GuardedF64> for f64
impl Add<GuardedF64> for f64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<UnguardedF64> for &GuardedF64
impl Add<UnguardedF64> for &GuardedF64
Source§fn add(self, rhs: UnguardedF64) -> Self::Output
fn add(self, rhs: UnguardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<UnguardedF64> for GuardedF64
impl Add<UnguardedF64> for GuardedF64
Source§fn add(self, rhs: UnguardedF64) -> Self::Output
fn add(self, rhs: UnguardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<f64> for &GuardedF64
impl Add<f64> for &GuardedF64
Source§fn add(self, rhs: f64) -> Self::Output
fn add(self, rhs: f64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add<f64> for GuardedF64
impl Add<f64> for GuardedF64
Source§fn add(self, rhs: f64) -> Self::Output
fn add(self, rhs: f64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Add for GuardedF64
impl Add for GuardedF64
Source§fn add(self, rhs: GuardedF64) -> Self::Output
fn add(self, rhs: GuardedF64) -> Self::Output
Adds two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!((value1 + value2).check().unwrap(), 5.0);
assert_eq!((value1 + f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
+ operator.Source§impl Clone for GuardedF64
impl Clone for GuardedF64
Source§fn clone(&self) -> GuardedF64
fn clone(&self) -> GuardedF64
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GuardedF64
impl Debug for GuardedF64
Source§impl Default for GuardedF64
impl Default for GuardedF64
Source§fn default() -> GuardedF64
fn default() -> GuardedF64
Source§impl Display for GuardedF64
impl Display for GuardedF64
Source§impl Div<&GuardedF64> for &GuardedF64
impl Div<&GuardedF64> for &GuardedF64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&GuardedF64> for &UnguardedF64
impl Div<&GuardedF64> for &UnguardedF64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&GuardedF64> for &f64
impl Div<&GuardedF64> for &f64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&GuardedF64> for GuardedF64
impl Div<&GuardedF64> for GuardedF64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&GuardedF64> for UnguardedF64
impl Div<&GuardedF64> for UnguardedF64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&GuardedF64> for f64
impl Div<&GuardedF64> for f64
Source§fn div(self, rhs: &GuardedF64) -> Self::Output
fn div(self, rhs: &GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&UnguardedF64> for &GuardedF64
impl Div<&UnguardedF64> for &GuardedF64
Source§fn div(self, rhs: &UnguardedF64) -> Self::Output
fn div(self, rhs: &UnguardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&UnguardedF64> for GuardedF64
impl Div<&UnguardedF64> for GuardedF64
Source§fn div(self, rhs: &UnguardedF64) -> Self::Output
fn div(self, rhs: &UnguardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&f64> for &GuardedF64
impl Div<&f64> for &GuardedF64
Source§fn div(self, rhs: &f64) -> Self::Output
fn div(self, rhs: &f64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<&f64> for GuardedF64
impl Div<&f64> for GuardedF64
Source§fn div(self, rhs: &f64) -> Self::Output
fn div(self, rhs: &f64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<GuardedF64> for &GuardedF64
impl Div<GuardedF64> for &GuardedF64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<GuardedF64> for &UnguardedF64
impl Div<GuardedF64> for &UnguardedF64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<GuardedF64> for &f64
impl Div<GuardedF64> for &f64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<GuardedF64> for UnguardedF64
impl Div<GuardedF64> for UnguardedF64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<GuardedF64> for f64
impl Div<GuardedF64> for f64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<UnguardedF64> for &GuardedF64
impl Div<UnguardedF64> for &GuardedF64
Source§fn div(self, rhs: UnguardedF64) -> Self::Output
fn div(self, rhs: UnguardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<UnguardedF64> for GuardedF64
impl Div<UnguardedF64> for GuardedF64
Source§fn div(self, rhs: UnguardedF64) -> Self::Output
fn div(self, rhs: UnguardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<f64> for &GuardedF64
impl Div<f64> for &GuardedF64
Source§fn div(self, rhs: f64) -> Self::Output
fn div(self, rhs: f64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div<f64> for GuardedF64
impl Div<f64> for GuardedF64
Source§fn div(self, rhs: f64) -> Self::Output
fn div(self, rhs: f64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl Div for GuardedF64
impl Div for GuardedF64
Source§fn div(self, rhs: GuardedF64) -> Self::Output
fn div(self, rhs: GuardedF64) -> Self::Output
Divides one GuardedF64 value by another or a f64 by a GuardedF64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(6.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 / value2), Ok(2.0));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / 0.0).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 / f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN / value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY / value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 / f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 / value2).check(), Err(FloatError::NaN));
assert_eq!((value2 / value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
/ operator.Source§impl From<GuardedF64> for UnguardedF64
impl From<GuardedF64> for UnguardedF64
Source§fn from(value: GuardedF64) -> Self
fn from(value: GuardedF64) -> Self
Converts a GuardedF64 into an UnguardedF64.
§Returns
Returns a new UnguardedF64 instance containing the inner f64 value.
§Example
use floatguard::{UnguardedF64, GuardedF64};
let checked_f64 = GuardedF64::new(3.14).unwrap();
let unchecked_f64 = UnguardedF64::from(checked_f64);
assert_eq!(unchecked_f64.check(), GuardedF64::new(3.14));Source§impl From<GuardedF64> for f64
Implementing the ability to convert GuardedF64 to f64 safely.
impl From<GuardedF64> for f64
Implementing the ability to convert GuardedF64 to f64 safely.
This conversion will return an error if the value is NaN or infinite.
Source§fn from(value: GuardedF64) -> Self
fn from(value: GuardedF64) -> Self
Converts a GuardedF64 to f64.
§Returns
Returns the inner f64 value if it is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{GuardedF64, FloatError};
let valid_value = GuardedF64::new(2.0).unwrap();
assert_eq!(valid_value.try_into(), Ok(2.0));
let invalid_value = GuardedF64::try_from(f64::NAN);
assert_eq!(invalid_value, Err(FloatError::NaN));
let inf_value = GuardedF64::try_from(f64::INFINITY);
assert_eq!(inf_value, Err(FloatError::Infinity));Source§impl Mul<&GuardedF64> for &GuardedF64
impl Mul<&GuardedF64> for &GuardedF64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&GuardedF64> for &UnguardedF64
impl Mul<&GuardedF64> for &UnguardedF64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&GuardedF64> for &f64
impl Mul<&GuardedF64> for &f64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&GuardedF64> for GuardedF64
impl Mul<&GuardedF64> for GuardedF64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&GuardedF64> for UnguardedF64
impl Mul<&GuardedF64> for UnguardedF64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&GuardedF64> for f64
impl Mul<&GuardedF64> for f64
Source§fn mul(self, rhs: &GuardedF64) -> Self::Output
fn mul(self, rhs: &GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&UnguardedF64> for &GuardedF64
impl Mul<&UnguardedF64> for &GuardedF64
Source§fn mul(self, rhs: &UnguardedF64) -> Self::Output
fn mul(self, rhs: &UnguardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&UnguardedF64> for GuardedF64
impl Mul<&UnguardedF64> for GuardedF64
Source§fn mul(self, rhs: &UnguardedF64) -> Self::Output
fn mul(self, rhs: &UnguardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&f64> for &GuardedF64
impl Mul<&f64> for &GuardedF64
Source§fn mul(self, rhs: &f64) -> Self::Output
fn mul(self, rhs: &f64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<&f64> for GuardedF64
impl Mul<&f64> for GuardedF64
Source§fn mul(self, rhs: &f64) -> Self::Output
fn mul(self, rhs: &f64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<GuardedF64> for &GuardedF64
impl Mul<GuardedF64> for &GuardedF64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<GuardedF64> for &UnguardedF64
impl Mul<GuardedF64> for &UnguardedF64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<GuardedF64> for &f64
impl Mul<GuardedF64> for &f64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<GuardedF64> for UnguardedF64
impl Mul<GuardedF64> for UnguardedF64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<GuardedF64> for f64
impl Mul<GuardedF64> for f64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<UnguardedF64> for &GuardedF64
impl Mul<UnguardedF64> for &GuardedF64
Source§fn mul(self, rhs: UnguardedF64) -> Self::Output
fn mul(self, rhs: UnguardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<UnguardedF64> for GuardedF64
impl Mul<UnguardedF64> for GuardedF64
Source§fn mul(self, rhs: UnguardedF64) -> Self::Output
fn mul(self, rhs: UnguardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<f64> for &GuardedF64
impl Mul<f64> for &GuardedF64
Source§fn mul(self, rhs: f64) -> Self::Output
fn mul(self, rhs: f64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul<f64> for GuardedF64
impl Mul<f64> for GuardedF64
Source§fn mul(self, rhs: f64) -> Self::Output
fn mul(self, rhs: f64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Mul for GuardedF64
impl Mul for GuardedF64
Source§fn mul(self, rhs: GuardedF64) -> Self::Output
fn mul(self, rhs: GuardedF64) -> Self::Output
Multiplies two GuardedF64 values or a GuardedF64 and a f64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(2.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 * value2), Ok(6.0));
assert_eq!((value1 * f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
* operator.Source§impl Neg for &GuardedF64
impl Neg for &GuardedF64
Source§fn neg(self) -> Self::Output
fn neg(self) -> Self::Output
Negates the GuardedF64 or UnguardedF64 value.
§Returns
Returns a new Self instance with the negated value. Unlike other operations, this does not
default to creating an UnguardedF64 for GuardedF64, as -x is always valid for finite
and non-NaN values.
§Example
use floatguard::{GuardedF64, FloatError, UnguardedF64};
let value = GuardedF64::new(2.0).unwrap();
assert_eq!(-value, -2.0);
let value = UnguardedF64::new(2.0);
assert_eq!(f64::try_from(-value), Ok(-2.0));
let invalid_value = UnguardedF64::new(f64::NAN);
assert_eq!((-invalid_value).check(), Err(FloatError::NaN));
let infinity_value = UnguardedF64::new(f64::INFINITY);
assert_eq!((-infinity_value).check(), Err(FloatError::Infinity));Source§type Output = GuardedF64
type Output = GuardedF64
- operator.Source§impl Neg for GuardedF64
impl Neg for GuardedF64
Source§fn neg(self) -> Self::Output
fn neg(self) -> Self::Output
Negates the GuardedF64 or UnguardedF64 value.
§Returns
Returns a new Self instance with the negated value. Unlike other operations, this does not
default to creating an UnguardedF64 for GuardedF64, as -x is always valid for finite
and non-NaN values.
§Example
use floatguard::{GuardedF64, FloatError, UnguardedF64};
let value = GuardedF64::new(2.0).unwrap();
assert_eq!(-value, -2.0);
let value = UnguardedF64::new(2.0);
assert_eq!(f64::try_from(-value), Ok(-2.0));
let invalid_value = UnguardedF64::new(f64::NAN);
assert_eq!((-invalid_value).check(), Err(FloatError::NaN));
let infinity_value = UnguardedF64::new(f64::INFINITY);
assert_eq!((-infinity_value).check(), Err(FloatError::Infinity));Source§type Output = GuardedF64
type Output = GuardedF64
- operator.Source§impl Ord for GuardedF64
impl Ord for GuardedF64
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares two GuardedF64 values.
§Returns
Returns Ordering if both values are valid (finite), otherwise panics.
§Example
use floatguard::GuardedF64;
let a = GuardedF64::new(2.0).unwrap();
let b = GuardedF64::new(3.0).unwrap();
assert_eq!(a.cmp(&b), std::cmp::Ordering::Less);
assert_eq!(b.cmp(&a), std::cmp::Ordering::Greater);
assert_eq!(a.cmp(&a), std::cmp::Ordering::Equal);1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq<GuardedF64> for f64
impl PartialEq<GuardedF64> for f64
Source§fn eq(&self, other: &GuardedF64) -> bool
fn eq(&self, other: &GuardedF64) -> bool
Compares f64 with GuardedF64 for equality.
§Returns
Returns true if f64 is finite and equal to GuardedF64, otherwise returns false.
§Example
use floatguard::GuardedF64;
let a = 2.0;
let b = GuardedF64::new(2.0).unwrap();
assert_eq!(a, b);
let a_invalid = f64::NAN;
let b_invalid = GuardedF64::new(2.0).unwrap();
assert_ne!(a_invalid, b_invalid);Source§impl PartialEq for GuardedF64
impl PartialEq for GuardedF64
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Compares two GuardedF64 values for equality.
§Returns
Returns true if both values are valid (finite) and equal, otherwise returns false.
§Example
use floatguard::GuardedF64;
let a = GuardedF64::new(2.0).unwrap();
let b = GuardedF64::new(2.0).unwrap();
assert_eq!(a, b);
let a_invalid = GuardedF64::new(2.0);
let b_invalid = GuardedF64::new(f64::NAN);
assert_ne!(a_invalid, b_invalid);Source§impl PartialOrd<GuardedF64> for f64
impl PartialOrd<GuardedF64> for f64
Source§fn partial_cmp(&self, other: &GuardedF64) -> Option<Ordering>
fn partial_cmp(&self, other: &GuardedF64) -> Option<Ordering>
Compares f64 with GuardedF64.
§Returns
Returns Some(Ordering) if both values are finite, otherwise returns None.
§Example
use floatguard::GuardedF64;
use std::cmp::Ordering;
let a = GuardedF64::new(2.0).unwrap();
let b = 3.0;
assert_eq!(a > b, false);
assert_eq!(a >= b, false);
assert_eq!(a < b, true);
assert_eq!(a <= b, true);
assert_eq!(f64::NAN.partial_cmp(&b), None);Source§impl PartialOrd<f64> for GuardedF64
impl PartialOrd<f64> for GuardedF64
Source§fn partial_cmp(&self, other: &f64) -> Option<Ordering>
fn partial_cmp(&self, other: &f64) -> Option<Ordering>
Compares GuardedF64 with f64.
§Returns
Returns Some(Ordering) if both values are valid (finite), otherwise returns None.
§Example
use floatguard::GuardedF64;
let a = GuardedF64::new(2.0).unwrap();
let b = 3.0;
assert_eq!(a < b, true);
assert_eq!(a <= b, true);
assert_eq!(a > b, false);
assert_eq!(a >= b, false);
let b_invalid = f64::NAN;
assert_eq!(a.partial_cmp(&b_invalid), None);Source§impl PartialOrd for GuardedF64
impl PartialOrd for GuardedF64
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Compares two GuardedF64 values.
§Returns
Returns Some(Ordering) if both values are valid (finite), otherwise returns None.
§Example
use floatguard::GuardedF64;
let a = GuardedF64::new(2.0).unwrap();
let b = GuardedF64::new(3.0).unwrap();
assert_eq!(a < b, true);
assert_eq!(a <= b, true);
assert_eq!(a > b, false);
assert_eq!(a >= b, false);Source§impl Rem<&GuardedF64> for &GuardedF64
impl Rem<&GuardedF64> for &GuardedF64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&GuardedF64> for &UnguardedF64
impl Rem<&GuardedF64> for &UnguardedF64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&GuardedF64> for &f64
impl Rem<&GuardedF64> for &f64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&GuardedF64> for GuardedF64
impl Rem<&GuardedF64> for GuardedF64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&GuardedF64> for UnguardedF64
impl Rem<&GuardedF64> for UnguardedF64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&GuardedF64> for f64
impl Rem<&GuardedF64> for f64
Source§fn rem(self, rhs: &GuardedF64) -> Self::Output
fn rem(self, rhs: &GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&UnguardedF64> for &GuardedF64
impl Rem<&UnguardedF64> for &GuardedF64
Source§fn rem(self, rhs: &UnguardedF64) -> Self::Output
fn rem(self, rhs: &UnguardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&UnguardedF64> for GuardedF64
impl Rem<&UnguardedF64> for GuardedF64
Source§fn rem(self, rhs: &UnguardedF64) -> Self::Output
fn rem(self, rhs: &UnguardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&f64> for &GuardedF64
impl Rem<&f64> for &GuardedF64
Source§fn rem(self, rhs: &f64) -> Self::Output
fn rem(self, rhs: &f64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<&f64> for GuardedF64
impl Rem<&f64> for GuardedF64
Source§fn rem(self, rhs: &f64) -> Self::Output
fn rem(self, rhs: &f64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<GuardedF64> for &GuardedF64
impl Rem<GuardedF64> for &GuardedF64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<GuardedF64> for &UnguardedF64
impl Rem<GuardedF64> for &UnguardedF64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<GuardedF64> for &f64
impl Rem<GuardedF64> for &f64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<GuardedF64> for UnguardedF64
impl Rem<GuardedF64> for UnguardedF64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<GuardedF64> for f64
impl Rem<GuardedF64> for f64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<UnguardedF64> for &GuardedF64
impl Rem<UnguardedF64> for &GuardedF64
Source§fn rem(self, rhs: UnguardedF64) -> Self::Output
fn rem(self, rhs: UnguardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<UnguardedF64> for GuardedF64
impl Rem<UnguardedF64> for GuardedF64
Source§fn rem(self, rhs: UnguardedF64) -> Self::Output
fn rem(self, rhs: UnguardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<f64> for &GuardedF64
impl Rem<f64> for &GuardedF64
Source§fn rem(self, rhs: f64) -> Self::Output
fn rem(self, rhs: f64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem<f64> for GuardedF64
impl Rem<f64> for GuardedF64
Source§fn rem(self, rhs: f64) -> Self::Output
fn rem(self, rhs: f64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Rem for GuardedF64
impl Rem for GuardedF64
Source§fn rem(self, rhs: GuardedF64) -> Self::Output
fn rem(self, rhs: GuardedF64) -> Self::Output
Computes the remainder of division between two GuardedF64 values or a GuardedF64 and
a f64.
§Example
use floatguard::{GuardedF64, UnguardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 % value2), Ok(2.0));
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % 0.0).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((value1 % f64::NAN).check(), Err(FloatError::NaN));
assert_eq!((f64::NAN % value1).check(), Err(FloatError::NaN));
let value1 = UnguardedF64::new(6.0);
assert_eq!((f64::INFINITY % value1).check(), Err(FloatError::Infinity));
assert_eq!((value1 % f64::INFINITY).check(), Err(FloatError::Infinity));
let value1 = UnguardedF64::new(f64::INFINITY);
let value2 = UnguardedF64::new(f64::NAN);
assert_eq!((value1 % value2).check(), Err(FloatError::NaN));
assert_eq!((value2 % value1).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
% operator.Source§impl Sub<&GuardedF64> for &GuardedF64
impl Sub<&GuardedF64> for &GuardedF64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&GuardedF64> for &UnguardedF64
impl Sub<&GuardedF64> for &UnguardedF64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&GuardedF64> for &f64
impl Sub<&GuardedF64> for &f64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&GuardedF64> for GuardedF64
impl Sub<&GuardedF64> for GuardedF64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&GuardedF64> for UnguardedF64
impl Sub<&GuardedF64> for UnguardedF64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&GuardedF64> for f64
impl Sub<&GuardedF64> for f64
Source§fn sub(self, rhs: &GuardedF64) -> Self::Output
fn sub(self, rhs: &GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&UnguardedF64> for &GuardedF64
impl Sub<&UnguardedF64> for &GuardedF64
Source§fn sub(self, rhs: &UnguardedF64) -> Self::Output
fn sub(self, rhs: &UnguardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&UnguardedF64> for GuardedF64
impl Sub<&UnguardedF64> for GuardedF64
Source§fn sub(self, rhs: &UnguardedF64) -> Self::Output
fn sub(self, rhs: &UnguardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&f64> for &GuardedF64
impl Sub<&f64> for &GuardedF64
Source§fn sub(self, rhs: &f64) -> Self::Output
fn sub(self, rhs: &f64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<&f64> for GuardedF64
impl Sub<&f64> for GuardedF64
Source§fn sub(self, rhs: &f64) -> Self::Output
fn sub(self, rhs: &f64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<GuardedF64> for &GuardedF64
impl Sub<GuardedF64> for &GuardedF64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<GuardedF64> for &UnguardedF64
impl Sub<GuardedF64> for &UnguardedF64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<GuardedF64> for &f64
impl Sub<GuardedF64> for &f64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<GuardedF64> for UnguardedF64
impl Sub<GuardedF64> for UnguardedF64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<GuardedF64> for f64
impl Sub<GuardedF64> for f64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<UnguardedF64> for &GuardedF64
impl Sub<UnguardedF64> for &GuardedF64
Source§fn sub(self, rhs: UnguardedF64) -> Self::Output
fn sub(self, rhs: UnguardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<UnguardedF64> for GuardedF64
impl Sub<UnguardedF64> for GuardedF64
Source§fn sub(self, rhs: UnguardedF64) -> Self::Output
fn sub(self, rhs: UnguardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<f64> for &GuardedF64
impl Sub<f64> for &GuardedF64
Source§fn sub(self, rhs: f64) -> Self::Output
fn sub(self, rhs: f64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub<f64> for GuardedF64
impl Sub<f64> for GuardedF64
Source§fn sub(self, rhs: f64) -> Self::Output
fn sub(self, rhs: f64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl Sub for GuardedF64
impl Sub for GuardedF64
Source§fn sub(self, rhs: GuardedF64) -> Self::Output
fn sub(self, rhs: GuardedF64) -> Self::Output
Subtracts one GuardedF64 value from another or a f64 from a GuardedF64.
§Example
use floatguard::{GuardedF64, FloatError};
let value1 = GuardedF64::new(5.0).unwrap();
let value2 = GuardedF64::new(3.0).unwrap();
assert_eq!(f64::try_from(value1 - value2), Ok(2.0));
assert_eq!((value1 - f64::NAN).check(), Err(FloatError::NaN));Source§type Output = UnguardedF64
type Output = UnguardedF64
- operator.Source§impl TryFrom<UnguardedF64> for GuardedF64
impl TryFrom<UnguardedF64> for GuardedF64
Source§fn try_from(value: UnguardedF64) -> Result<Self, Self::Error>
fn try_from(value: UnguardedF64) -> Result<Self, Self::Error>
Converts an UnguardedF64 to GuardedF64.
§Returns
Returns a GuardedF64 if the value is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{UnguardedF64, FloatError, GuardedF64};
let valid_value = UnguardedF64::new(2.0);
assert_eq!(valid_value.try_into(), GuardedF64::new(2.0));
let invalid_value = UnguardedF64::new(f64::NAN);
assert_eq!(GuardedF64::try_from(invalid_value), Err(FloatError::NaN));
let inf_value = UnguardedF64::new(f64::INFINITY);
assert_eq!(GuardedF64::try_from(inf_value), Err(FloatError::Infinity));Source§impl TryFrom<f64> for GuardedF64
impl TryFrom<f64> for GuardedF64
Source§fn try_from(value: f64) -> Result<Self, Self::Error>
fn try_from(value: f64) -> Result<Self, Self::Error>
Converts a f64 to GuardedF64.
§Returns
Returns a GuardedF64 if the value is valid (finite), otherwise returns an error.
§Errors
Returns FloatError if the value is NaN or infinite.
§Example
use floatguard::{GuardedF64, FloatError};
let valid_value = GuardedF64::new(2.0);
assert!(valid_value.is_ok());
let invalid_value = GuardedF64::new(f64::NAN);
assert!(invalid_value.is_err());
let inf_value = GuardedF64::new(f64::INFINITY);
assert!(inf_value.is_err());