pub struct TwoFloat { /* private fields */ }
Expand description
Represents a two-word floating point type, represented as the sum of two non-overlapping f64 values.
Implementations§
source§impl TwoFloat
impl TwoFloat
sourcepub fn new_add(a: f64, b: f64) -> Self
pub fn new_add(a: f64, b: f64) -> Self
Creates a new TwoFloat
by adding two f64
values using Algorithm 2
from Joldes et al. (2017).
sourcepub fn new_sub(a: f64, b: f64) -> Self
pub fn new_sub(a: f64, b: f64) -> Self
Creates a new TwoFloat
by subtracting two f64
values using
Algorithm 2 from Joldes et al. (2017) modified for negative right-hand
side.
source§impl TwoFloat
impl TwoFloat
sourcepub fn div_euclid(self, rhs: Self) -> Self
pub fn div_euclid(self, rhs: Self) -> Self
Calculates Euclidean division, the matching method for rem_euclid
.
Examples
let a = TwoFloat::from(9.0);
let b = TwoFloat::from(5.0);
assert_eq!(a.div_euclid(b), TwoFloat::from(1.0));
assert_eq!((-a).div_euclid(b), TwoFloat::from(-2.0));
assert_eq!(a.div_euclid(-b), TwoFloat::from(-1.0));
assert_eq!((-a).div_euclid(-b), TwoFloat::from(2.0));
sourcepub fn rem_euclid(self, rhs: Self) -> Self
pub fn rem_euclid(self, rhs: Self) -> Self
Calculates the least nonnegative remainder of self (mod rhs)
.
The return value r
usually satisfies 0.0 <= r < rhs.abs()
,
although the errors in numerical computation may result in violations
of this constraint.
Examples
let a = TwoFloat::from(9.0);
let b = TwoFloat::from(5.0);
assert_eq!(a.rem_euclid(b), TwoFloat::from(4.0));
assert_eq!((-a).rem_euclid(b), TwoFloat::from(1.0));
assert_eq!(a.rem_euclid(-b), TwoFloat::from(4.0));
assert_eq!((-a).rem_euclid(-b), TwoFloat::from(1.0));
source§impl TwoFloat
impl TwoFloat
sourcepub const MIN_POSITIVE: Self = _
pub const MIN_POSITIVE: Self = _
Smallest positive normal TwoFloat
value.
sourcepub const EPSILON: Self = _
pub const EPSILON: Self = _
Represents the difference between 1.0 and the next representable normal value.
sourcepub const NEG_INFINITY: Self = _
pub const NEG_INFINITY: Self = _
A negative infinite value
sourcepub const fn from_f64(value: f64) -> Self
pub const fn from_f64(value: f64) -> Self
Creates a new TwoFloat from a constant f64
value.
Examples
const value: TwoFloat = TwoFloat::from_f64(1.0);
assert_eq!(value.hi(), 1.0);
sourcepub fn hi(&self) -> f64
pub fn hi(&self) -> f64
Returns the high word of self
.
Examples
let value = TwoFloat::new_add(1.0, -1.0e-200);
assert_eq!(value.hi(), 1.0);
sourcepub fn lo(&self) -> f64
pub fn lo(&self) -> f64
Returns the low word of self
.
Examples
let value = TwoFloat::new_add(1.0, -1.0e-200);
assert_eq!(value.lo(), -1.0e-200);
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if self
is a valid value, where both components are
finite (not infinity or NAN
).
Examples
let a = TwoFloat::new_add(1.0, 1.0e-300).is_valid();
let b = TwoFloat::new_mul(1.0e300, 1.0e300).is_valid();
assert!(a);
assert!(!b);
sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum of two numbers. If one of the arguments is NAN
,
the other is returned.
Examples
let a = TwoFloat::new_add(35.2, 1e-84);
let b = TwoFloat::new_add(35.2, -1e-93);
assert_eq!(a.min(b), b);
sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum of two numbers. If one of the arguments is NAN
,
the other is returned.
Examples
let a = TwoFloat::new_add(35.2, 1e-84);
let b = TwoFloat::new_add(35.2, -1e-93);
assert_eq!(a.max(b), a);
sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
Converts degrees to radians.
Examples
let a = TwoFloat::from(90.0);
let b = a.to_radians();
assert!((b - twofloat::consts::FRAC_PI_2).abs() < 1e-16);
sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
Converts radians to degrees.
Examples
let a = twofloat::consts::PI;
let b = a.to_degrees();
assert!((b - 180.0).abs() < 1e-16);
source§impl TwoFloat
impl TwoFloat
sourcepub fn fract(self) -> Self
pub fn fract(self) -> Self
Returns the fractional part of the number.
Examples
let a = TwoFloat::new_add(1.0, 1e-200).fract();
let b = TwoFloat::new_add(-1.0, 1e-200).fract();
assert_eq!(a, TwoFloat::from(1e-200));
assert_eq!(b, TwoFloat::new_add(-1.0, 1e-200));
sourcepub fn trunc(self) -> Self
pub fn trunc(self) -> Self
Returns the integer part of the number.
Examples
let a = TwoFloat::new_add(1.0, 1e-200).trunc();
let b = TwoFloat::new_add(1.0, -1e-200).trunc();
assert_eq!(a, TwoFloat::from(1.0));
assert_eq!(b, TwoFloat::from(0.0));
sourcepub fn ceil(self) -> Self
pub fn ceil(self) -> Self
Returns the smallest integer greater than or equal to the number.
Examples
let a = TwoFloat::new_add(1.0, 1e-200).ceil();
let b = TwoFloat::new_add(1.0, -1e-200).ceil();
let c = TwoFloat::new_add(-1.0, 1e-200).ceil();
assert_eq!(a, TwoFloat::from(2.0));
assert_eq!(b, TwoFloat::from(1.0));
assert_eq!(c, TwoFloat::from(0.0));
sourcepub fn floor(self) -> Self
pub fn floor(self) -> Self
Returns the smallest integer less than or equal to the number.
Examples
let a = TwoFloat::new_add(1.0, 1e-200).floor();
let b = TwoFloat::new_add(1.0, -1e-200).floor();
let c = TwoFloat::new_add(-1.0, 1e-200).floor();
assert_eq!(a, TwoFloat::from(1.0));
assert_eq!(b, TwoFloat::from(0.0));
assert_eq!(c, TwoFloat::from(-1.0));
sourcepub fn round(self) -> Self
pub fn round(self) -> Self
Returns the nearest integer to the value. Round half-way cases away
from 0.0
.
Examples
let a = TwoFloat::new_add(1.0, 1e-200).round();
let b = TwoFloat::new_add(1.0, -1e-200).round();
let c = TwoFloat::from(-0.5).round();
assert_eq!(a, TwoFloat::from(1.0));
assert_eq!(b, TwoFloat::from(1.0));
assert_eq!(c, TwoFloat::from(-1.0));
source§impl TwoFloat
impl TwoFloat
sourcepub fn abs(&self) -> Self
pub fn abs(&self) -> Self
Returns the absolute value root of self
.
Examples
let a = TwoFloat::new_add(1.0, 1.0e-300).abs();
let b = TwoFloat::new_add(-1.0, 1.0e-300).abs();
assert_eq!(a, TwoFloat::new_add(1.0, 1.0e-300));
assert_eq!(b, TwoFloat::new_add(1.0, -1.0e-300));
sourcepub fn is_sign_positive(&self) -> bool
pub fn is_sign_positive(&self) -> bool
Returns true
if self
has a positive sign, including +0.0
.
Examples
let a = TwoFloat::new_add(0.0, 0.0).is_sign_positive();
let b = TwoFloat::new_add(1.0, 1.0e-300).is_sign_positive();
let c = TwoFloat::new_add(-1.0, 1.0e-300).is_sign_positive();
assert!(a);
assert!(b);
assert!(!c);
sourcepub fn is_sign_negative(&self) -> bool
pub fn is_sign_negative(&self) -> bool
Returns true
if self
has a negative sign, including -0.0
.
Examples
let a = TwoFloat::new_add(-1.0, 1.0e-300).is_sign_negative();
let b = TwoFloat::new_add(0.0, 0.0).is_sign_negative();
let c = TwoFloat::new_add(1.0, 1.0e-300).is_sign_negative();
assert!(a);
assert!(!b);
assert!(!c);
sourcepub fn copysign(&self, sign: &Self) -> Self
pub fn copysign(&self, sign: &Self) -> Self
Returns a number composed of the magnitude of self
and the sign of
sign
.
Equal to self
if the sign of self
and sign
are the same,
otherwise equal to -self
.
Examples
let a = TwoFloat::new_add(-1.0, 1.0e-200);
let b = TwoFloat::new_add(1.0, 0.3);
let c = a.copysign(&b);
assert_eq!(c, -a);
sourcepub fn signum(&self) -> Self
pub fn signum(&self) -> Self
Returns a number that represents the sign of the value.
1.0
if the number is positive or+0.0
-1.0
if the number is negative or-0.0
- Invalid value otherwise
Examples
use twofloat::TwoFloat;
let a = TwoFloat::from(3.5); let b = TwoFloat::from(-0.0);
assert_eq!(a.signum(), 1.0); assert_eq!(b.signum(), -1.0);
source§impl TwoFloat
impl TwoFloat
sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
Returns e^(self)
, (the exponential function).
Examples
let a = TwoFloat::from(2.0);
let b = a.exp();
let e2 = twofloat::consts::E * twofloat::consts::E;
assert!((b - e2).abs() / e2 < 1e-16);
sourcepub fn exp_m1(self) -> Self
pub fn exp_m1(self) -> Self
Returns e^(self) - 1
in a way that provides additional accuracy
when the value is close to zero.
Examples
let a = TwoFloat::from(0.05);
let b = a.exp_m1();
let c = 0.05f64.exp_m1();
assert!((b - c).abs() < 1e-16);
sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
Returns 2^(self)
.
Examples
let a = TwoFloat::from(0.5).exp2();
let b = TwoFloat::from(2).sqrt();
assert!((a - b).abs() < 1e-15);
sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
Returns the natural logarithm of the value.
Uses Newton–Raphson iteration which depends on the exp
function, so
may not be fully accurate to the full precision of a TwoFloat
.
Example
let a = twofloat::consts::E.ln();
assert!((a - 1.0).abs() < 1e-11);
sourcepub fn ln_1p(self) -> Self
pub fn ln_1p(self) -> Self
Returns the natural logarithm of 1 + self
.
Uses Newton–Raphson iteration which depends on the expm1
function,
so may not be fully accurate to the full precision of a TwoFloat
.
Example
let a = TwoFloat::from(0.1);
let b = a.ln_1p();
let c = 0.1f64.ln_1p();
assert!((b - c).abs() < 1e-10);
sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
Returns the logarithm of the number with respect to an arbitrary base.
This is a convenience method that computes self.ln() / base.ln()
, no
additional accuracy is provided.
Examples
let a = TwoFloat::from(81.0); let b = TwoFloat::from(3.0); let c = TwoFloat::log(a, b);
assert!((c - 4.0).abs() < 1e-12);
source§impl TwoFloat
impl TwoFloat
sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
Hyperbolic cosine function.
This is a convenience method that computes the value by calling the exponential function.
Examples
let a = TwoFloat::from(2.0);
let b = a.cosh();
let c = 2.0f64.cosh();
assert!((b - c).abs() < 1e-10);
sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
Hyperbolic sine function.
This is a convenience method that computes the value by calling the exponential function.
Examples
let a = TwoFloat::from(2.0);
let b = a.sinh();
let c = 2.0f64.sinh();
assert!((b - c).abs() < 1e-10);
sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
Hyperbolic tangent function.
This is a convenience method that computes the value by calling the exponential function.
Examples
let a = TwoFloat::from(2.0);
let b = a.tanh();
let c = 2.0f64.tanh();
assert!((b - c).abs() < 1e-10);
sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
Inverse hyperbolic cosine function.
This is a convenience method that computes the value by calling the
sqrt
and ln
functions.
Examples
let a = TwoFloat::from(2.0);
let b = a.acosh();
let c = 2.0f64.acosh();
assert!((b - c).abs() < 1e-10);
source§impl TwoFloat
impl TwoFloat
sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Returns the square root of the number, using equation 4 from Karp & Markstein (1997).
Examples
let a = TwoFloat::from(2.0);
let b = a.sqrt();
assert!(b * b - a < 1e-16);
sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Returns the cube root of the number, using Newton-Raphson iteration.
Examples
let a = TwoFloat::new_add(1.4e53, 0.21515);
let b = a.cbrt();
assert!(b.powi(3) - a < 1e-16);
source§impl TwoFloat
impl TwoFloat
sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
Computes the sine of the value (in radians).
Examples
let a = TwoFloat::from(2.5);
let b = a.sin();
let c = 2.5f64.sin();
assert!((b - c).abs() < 1e-10);
sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
Computes the cosine of the value (in radians)
Examples
let a = TwoFloat::from(2.5);
let b = a.cos();
let c = 2.5f64.cos();
assert!((b - c).abs() < 1e-10);
sourcepub fn sin_cos(self) -> (Self, Self)
pub fn sin_cos(self) -> (Self, Self)
Simultaneously computes the sine and cosine of the value. Returns a tuple with the sine as the first element and the cosine as the second element.
Examples
let a = TwoFloat::from(2.5);
let (s, c) = a.sin_cos();
assert!((s - 2.5f64.sin()).abs() < 1e-10);
assert!((c - 2.5f64.cos()).abs() < 1e-10);
sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
Computes the tangent of the value (in radians).
Examples
let a = TwoFloat::from(2.5);
let b = a.tan();
let c = 2.5f64.tan();
assert!((b - c).abs() < 1e-10);
sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
Computes the arcsine of the value. Return value is in radians in the range [-π/2, π/2] or an invalid value if the input value is outside the range [-1, 1].
Examples
let a = TwoFloat::from(0.7);
let b = a.asin();
let c = 0.7f64.asin();
assert!((b - c).abs() < 1e-10);
sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
Computes the arccosine of the value. Return value is in radians in the range [0, π] or an invalid value if the input value is outside the range [-1, 1].
Examples
let a = TwoFloat::from(-0.8);
let b = a.acos();
let c = (-0.8f64).acos();
assert!((b - c).abs() < 1e-10);
Trait Implementations§
source§impl<'a> AddAssign<&'a TwoFloat> for TwoFloat
impl<'a> AddAssign<&'a TwoFloat> for TwoFloat
source§fn add_assign(&mut self, rhs: &'a TwoFloat)
fn add_assign(&mut self, rhs: &'a TwoFloat)
Implements addition of two TwoFloat
values using Joldes et al.
(2017) Algorithm 6.
source§impl<'a> AddAssign<&'a f64> for TwoFloat
impl<'a> AddAssign<&'a f64> for TwoFloat
source§fn add_assign(&mut self, rhs: &'a f64)
fn add_assign(&mut self, rhs: &'a f64)
Implements addition of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 4.
source§impl<'a> AddAssign<TwoFloat> for TwoFloat
impl<'a> AddAssign<TwoFloat> for TwoFloat
source§fn add_assign(&mut self, rhs: TwoFloat)
fn add_assign(&mut self, rhs: TwoFloat)
Implements addition of two TwoFloat
values using Joldes et al.
(2017) Algorithm 6.
source§impl<'a> AddAssign<f64> for TwoFloat
impl<'a> AddAssign<f64> for TwoFloat
source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
Implements addition of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 4.
source§impl<'de> Deserialize<'de> for TwoFloat
impl<'de> Deserialize<'de> for TwoFloat
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<'a> DivAssign<&'a TwoFloat> for TwoFloat
impl<'a> DivAssign<&'a TwoFloat> for TwoFloat
source§fn div_assign(&mut self, rhs: &'a TwoFloat)
fn div_assign(&mut self, rhs: &'a TwoFloat)
Implements division of two TwoFloat
values using Joldes et al.
(2017) Algorithm 18.
source§impl<'a> DivAssign<&'a f64> for TwoFloat
impl<'a> DivAssign<&'a f64> for TwoFloat
source§fn div_assign(&mut self, rhs: &'a f64)
fn div_assign(&mut self, rhs: &'a f64)
Implements division of TwoFloat
and f64
using Joldes et al. (2017)
Algorithm 15
source§impl<'a> DivAssign<TwoFloat> for TwoFloat
impl<'a> DivAssign<TwoFloat> for TwoFloat
source§fn div_assign(&mut self, rhs: TwoFloat)
fn div_assign(&mut self, rhs: TwoFloat)
Implements division of two TwoFloat
values using Joldes et al.
(2017) Algorithm 18.
source§impl<'a> DivAssign<f64> for TwoFloat
impl<'a> DivAssign<f64> for TwoFloat
source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
Implements division of TwoFloat
and f64
using Joldes et al. (2017)
Algorithm 15
source§impl Float for TwoFloat
impl Float for TwoFloat
source§fn neg_infinity() -> Self
fn neg_infinity() -> Self
source§fn min_value() -> Self
fn min_value() -> Self
source§fn min_positive_value() -> Self
fn min_positive_value() -> Self
source§fn max_value() -> Self
fn max_value() -> Self
source§fn classify(self) -> FpCategory
fn classify(self) -> FpCategory
source§fn to_degrees(self) -> Self
fn to_degrees(self) -> Self
source§fn to_radians(self) -> Self
fn to_radians(self) -> Self
source§fn integer_decode(self) -> (u64, i16, i8)
fn integer_decode(self) -> (u64, i16, i8)
sign * mantissa * 2 ^ exponent
. Read moresource§fn is_infinite(self) -> bool
fn is_infinite(self) -> bool
true
if this value is positive infinity or negative infinity and
false otherwise. Read moresource§fn ceil(self) -> Self
fn ceil(self) -> Self
source§fn round(self) -> Self
fn round(self) -> Self
0.0
. Read moresource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true
if self
is positive, including +0.0
,
Float::infinity()
, and since Rust 1.20 also Float::nan()
. Read moresource§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true
if self
is negative, including -0.0
,
Float::neg_infinity()
, and since Rust 1.20 also -Float::nan()
. Read moresource§fn mul_add(self, a: Self, b: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
(self * a) + b
with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moresource§fn log(self, base: Self) -> Self
fn log(self, base: Self) -> Self
source§fn hypot(self, other: Self) -> Self
fn hypot(self, other: Self) -> Self
x
and y
. Read moresource§fn asin(self) -> Self
fn asin(self) -> Self
source§fn acos(self) -> Self
fn acos(self) -> Self
source§fn atan(self) -> Self
fn atan(self) -> Self
source§fn sin_cos(self) -> (Self, Self)
fn sin_cos(self) -> (Self, Self)
source§fn exp_m1(self) -> Self
fn exp_m1(self) -> Self
e^(self) - 1
in a way that is accurate even if the
number is close to zero. Read moresource§impl FloatConst for TwoFloat
impl FloatConst for TwoFloat
source§fn FRAC_1_SQRT_2() -> Self
fn FRAC_1_SQRT_2() -> Self
1.0 / sqrt(2.0)
.source§fn FRAC_2_SQRT_PI() -> Self
fn FRAC_2_SQRT_PI() -> Self
2.0 / sqrt(π)
.source§impl FloatCore for TwoFloat
impl FloatCore for TwoFloat
source§fn neg_infinity() -> Self
fn neg_infinity() -> Self
source§fn min_value() -> Self
fn min_value() -> Self
source§fn min_positive_value() -> Self
fn min_positive_value() -> Self
source§fn max_value() -> Self
fn max_value() -> Self
source§fn classify(self) -> FpCategory
fn classify(self) -> FpCategory
source§fn to_degrees(self) -> Self
fn to_degrees(self) -> Self
source§fn to_radians(self) -> Self
fn to_radians(self) -> Self
source§fn integer_decode(self) -> (u64, i16, i8)
fn integer_decode(self) -> (u64, i16, i8)
sign * mantissa * 2 ^ exponent
. Read moresource§fn is_infinite(self) -> bool
fn is_infinite(self) -> bool
true
if the number is infinite. Read moresource§fn is_normal(self) -> bool
fn is_normal(self) -> bool
true
if the number is neither zero, infinite, subnormal or NaN. Read moresource§fn ceil(self) -> Self
fn ceil(self) -> Self
source§fn round(self) -> Self
fn round(self) -> Self
0.0
. Read moresource§fn abs(self) -> Self
fn abs(self) -> Self
self
. Returns FloatCore::nan()
if the
number is FloatCore::nan()
. Read moresource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true
if self
is positive, including +0.0
and
FloatCore::infinity()
, and since Rust 1.20 also
FloatCore::nan()
. Read moresource§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true
if self
is negative, including -0.0
and
FloatCore::neg_infinity()
, and since Rust 1.20 also
-FloatCore::nan()
. Read moresource§impl FromPrimitive for TwoFloat
impl FromPrimitive for TwoFloat
source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§impl<'a> MulAssign<&'a TwoFloat> for TwoFloat
impl<'a> MulAssign<&'a TwoFloat> for TwoFloat
source§fn mul_assign(&mut self, rhs: &'a TwoFloat)
fn mul_assign(&mut self, rhs: &'a TwoFloat)
Implements multiplication of two TwoFloat
values using Joldes et al.
(2017) Algorithm 12.
source§impl<'a> MulAssign<&'a f64> for TwoFloat
impl<'a> MulAssign<&'a f64> for TwoFloat
source§fn mul_assign(&mut self, rhs: &'a f64)
fn mul_assign(&mut self, rhs: &'a f64)
Implements multiplication of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 9.
source§impl<'a> MulAssign<TwoFloat> for TwoFloat
impl<'a> MulAssign<TwoFloat> for TwoFloat
source§fn mul_assign(&mut self, rhs: TwoFloat)
fn mul_assign(&mut self, rhs: TwoFloat)
Implements multiplication of two TwoFloat
values using Joldes et al.
(2017) Algorithm 12.
source§impl<'a> MulAssign<f64> for TwoFloat
impl<'a> MulAssign<f64> for TwoFloat
source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Implements multiplication of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 9.
source§impl Num for TwoFloat
impl Num for TwoFloat
type FromStrRadixErr = TwoFloatError
source§fn from_str_radix(
_str: &str,
_radix: u32
) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix( _str: &str, _radix: u32 ) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl PartialEq<TwoFloat> for TwoFloat
impl PartialEq<TwoFloat> for TwoFloat
source§impl PartialEq<TwoFloat> for f64
impl PartialEq<TwoFloat> for f64
source§impl PartialOrd<TwoFloat> for TwoFloat
impl PartialOrd<TwoFloat> for TwoFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<TwoFloat> for f64
impl PartialOrd<TwoFloat> for f64
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<f64> for TwoFloat
impl PartialOrd<f64> for TwoFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> RemAssign<&'a TwoFloat> for TwoFloat
impl<'a> RemAssign<&'a TwoFloat> for TwoFloat
source§fn rem_assign(&mut self, rhs: &'a TwoFloat)
fn rem_assign(&mut self, rhs: &'a TwoFloat)
%=
operation. Read moresource§impl<'b> RemAssign<&'b f64> for TwoFloat
impl<'b> RemAssign<&'b f64> for TwoFloat
source§fn rem_assign(&mut self, rhs: &'b f64)
fn rem_assign(&mut self, rhs: &'b f64)
%=
operation. Read moresource§impl<'a> RemAssign<TwoFloat> for TwoFloat
impl<'a> RemAssign<TwoFloat> for TwoFloat
source§fn rem_assign(&mut self, rhs: TwoFloat)
fn rem_assign(&mut self, rhs: TwoFloat)
%=
operation. Read moresource§impl<'b> RemAssign<f64> for TwoFloat
impl<'b> RemAssign<f64> for TwoFloat
source§fn rem_assign(&mut self, rhs: f64)
fn rem_assign(&mut self, rhs: f64)
%=
operation. Read moresource§impl Signed for TwoFloat
impl Signed for TwoFloat
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
source§impl<'a> SubAssign<&'a TwoFloat> for TwoFloat
impl<'a> SubAssign<&'a TwoFloat> for TwoFloat
source§fn sub_assign(&mut self, rhs: &'a TwoFloat)
fn sub_assign(&mut self, rhs: &'a TwoFloat)
Implements subtraction of two TwoFloat
values using Joldes et al.
(2017) Algorithm 6 modified for a negative right-hand side.
source§impl<'a> SubAssign<&'a f64> for TwoFloat
impl<'a> SubAssign<&'a f64> for TwoFloat
source§fn sub_assign(&mut self, rhs: &'a f64)
fn sub_assign(&mut self, rhs: &'a f64)
Implements subtraction of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 4 modified for negative right-hand side.
source§impl<'a> SubAssign<TwoFloat> for TwoFloat
impl<'a> SubAssign<TwoFloat> for TwoFloat
source§fn sub_assign(&mut self, rhs: TwoFloat)
fn sub_assign(&mut self, rhs: TwoFloat)
Implements subtraction of two TwoFloat
values using Joldes et al.
(2017) Algorithm 6 modified for a negative right-hand side.
source§impl<'a> SubAssign<f64> for TwoFloat
impl<'a> SubAssign<f64> for TwoFloat
source§fn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
Implements subtraction of TwoFloat
and f64
using Joldes et al.
(2017) Algorithm 4 modified for negative right-hand side.
source§impl ToPrimitive for TwoFloat
impl ToPrimitive for TwoFloat
source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moresource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read moresource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.impl Copy for TwoFloat
Auto Trait Implementations§
impl RefUnwindSafe for TwoFloat
impl Send for TwoFloat
impl Sync for TwoFloat
impl Unpin for TwoFloat
impl UnwindSafe for TwoFloat
Blanket Implementations§
source§impl<T> LowerBounded for Twhere
T: Bounded,
impl<T> LowerBounded for Twhere T: Bounded,
source§impl<T> Real for Twhere
T: Float,
impl<T> Real for Twhere T: Float,
source§fn min_positive_value() -> T
fn min_positive_value() -> T
source§fn round(self) -> T
fn round(self) -> T
0.0
. Read moresource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true
if self
is positive, including +0.0
,
Float::infinity()
, and with newer versions of Rust f64::NAN
. Read moresource§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true
if self
is negative, including -0.0
,
Float::neg_infinity()
, and with newer versions of Rust -f64::NAN
. Read moresource§fn mul_add(self, a: T, b: T) -> T
fn mul_add(self, a: T, b: T) -> T
(self * a) + b
with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moresource§fn log(self, base: T) -> T
fn log(self, base: T) -> T
source§fn to_degrees(self) -> T
fn to_degrees(self) -> T
source§fn to_radians(self) -> T
fn to_radians(self) -> T
source§fn hypot(self, other: T) -> T
fn hypot(self, other: T) -> T
x
and y
. Read moresource§fn asin(self) -> T
fn asin(self) -> T
source§fn acos(self) -> T
fn acos(self) -> T
source§fn atan(self) -> T
fn atan(self) -> T
source§fn exp_m1(self) -> T
fn exp_m1(self) -> T
e^(self) - 1
in a way that is accurate even if the
number is close to zero. Read more