pub struct FloatWrapper(pub Float);
regression
and arbitrary-precision
only.Expand description
A wrapper around rug::Float
to implement traits for.
Tuple Fields§
§0: Float
Methods from Deref<Target = Float>§
sourcepub fn prec_64(&self) -> u64
pub fn prec_64(&self) -> u64
Returns the precision.
§Examples
use rug::Float;
let f = Float::new_64(53);
assert_eq!(f.prec_64(), 53);
sourcepub fn as_raw(&self) -> *const mpfr_t
pub fn as_raw(&self) -> *const mpfr_t
Returns a pointer to the inner MPFR floating-point number.
The returned pointer will be valid for as long as self
is valid.
§Examples
use gmp_mpfr_sys::mpfr;
use gmp_mpfr_sys::mpfr::rnd_t;
use rug::Float;
let f = Float::with_val(53, -14.5);
let m_ptr = f.as_raw();
unsafe {
let d = mpfr::get_d(m_ptr, rnd_t::RNDN);
assert_eq!(d, -14.5);
}
// f is still valid
assert_eq!(f, -14.5);
sourcepub fn to_integer(&self) -> Option<Integer>
Available on crate feature integer
only.
pub fn to_integer(&self) -> Option<Integer>
integer
only.If the value is a finite number, converts it to an
Integer
rounding to the nearest.
This conversion can also be performed using
(&float).checked_as::<Integer>()
float.borrow().checked_as::<Integer>()
float.checked_as::<Integer>()
§Examples
use rug::Float;
let f = Float::with_val(53, 13.7);
let i = match f.to_integer() {
Some(i) => i,
None => unreachable!(),
};
assert_eq!(i, 14);
sourcepub fn to_integer_round(&self, round: Round) -> Option<(Integer, Ordering)>
Available on crate feature integer
only.
pub fn to_integer_round(&self, round: Round) -> Option<(Integer, Ordering)>
integer
only.If the value is a finite number, converts it to an
Integer
applying the specified rounding method.
§Examples
use core::cmp::Ordering;
use rug::float::Round;
use rug::Float;
let f = Float::with_val(53, 13.7);
let (i, dir) = match f.to_integer_round(Round::Down) {
Some(i_dir) => i_dir,
None => unreachable!(),
};
assert_eq!(i, 13);
assert_eq!(dir, Ordering::Less);
sourcepub fn to_integer_exp(&self) -> Option<(Integer, i32)>
Available on crate feature integer
only.
pub fn to_integer_exp(&self) -> Option<(Integer, i32)>
integer
only.If the value is a finite number, returns an
Integer
and exponent such that it is exactly equal to the integer
multiplied by two raised to the power of the exponent.
§Examples
use rug::float::Special;
use rug::{Assign, Float};
let mut float = Float::with_val(16, 6.5);
// 6.5 in binary is 110.1
// Since the precision is 16 bits, this becomes
// 1101_0000_0000_0000 times two to the power of -12
let (int, exp) = float.to_integer_exp().unwrap();
assert_eq!(int, 0b1101_0000_0000_0000);
assert_eq!(exp, -13);
float.assign(0);
let (zero, _) = float.to_integer_exp().unwrap();
assert_eq!(zero, 0);
float.assign(Special::Infinity);
assert!(float.to_integer_exp().is_none());
Going back from the returned Integer
and exponent to the original
can be done by assigning the Integer
and shifting to the left by the
exponent.
use rug::{Assign, Float};
let orig = Float::with_val(16, 6.5);
let (int, exp) = orig.to_integer_exp().unwrap();
let mut float = Float::new(16);
float.assign(&int);
float <<= exp;
assert_eq!(float, orig);
sourcepub fn to_rational(&self) -> Option<Rational>
Available on crate feature rational
only.
pub fn to_rational(&self) -> Option<Rational>
rational
only.If the value is a finite number, returns a
Rational
number preserving all the precision of the value.
This conversion can also be performed using
Rational::try_from(&float)
Rational::try_from(float)
(&float).checked_as::<Rational>()
float.borrow().checked_as::<Rational>()
float.checked_as::<Rational>()
§Examples
use core::cmp::Ordering;
use core::str::FromStr;
use rug::float::Round;
use rug::{Float, Rational};
// Consider the number 123,456,789 / 10,000,000,000.
let parse = Float::parse("0.0123456789").unwrap();
let (f, f_rounding) = Float::with_val_round(35, parse, Round::Down);
assert_eq!(f_rounding, Ordering::Less);
let r = Rational::from_str("123456789/10000000000").unwrap();
// Set fr to the value of f exactly.
let fr = f.to_rational().unwrap();
// Since f == fr and f was rounded down, r != fr.
assert_ne!(r, fr);
let (frf, frf_rounding) = Float::with_val_round(35, &fr, Round::Down);
assert_eq!(frf_rounding, Ordering::Equal);
assert_eq!(frf, f);
assert_eq!(format!("{:.9}", frf), "1.23456789e-2");
In the following example, the Float
values can be represented
exactly.
use rug::Float;
let large_f = Float::with_val(16, 6.5);
let large_r = large_f.to_rational().unwrap();
let small_f = Float::with_val(16, -0.125);
let small_r = small_f.to_rational().unwrap();
assert_eq!(*large_r.numer(), 13);
assert_eq!(*large_r.denom(), 2);
assert_eq!(*small_r.numer(), -1);
assert_eq!(*small_r.denom(), 8);
sourcepub fn to_i32_saturating(&self) -> Option<i32>
pub fn to_i32_saturating(&self) -> Option<i32>
Converts to an i32
, rounding to the nearest.
If the value is too small or too large for the target type, the minimum
or maximum value allowed is returned. If the value is a NaN, None
is
returned.
§Examples
use rug::{Assign, Float};
let mut f = Float::with_val(53, -13.7);
assert_eq!(f.to_i32_saturating(), Some(-14));
f.assign(-1e40);
assert_eq!(f.to_i32_saturating(), Some(i32::MIN));
f.assign(u32::MAX);
assert_eq!(f.to_i32_saturating(), Some(i32::MAX));
sourcepub fn to_i32_saturating_round(&self, round: Round) -> Option<i32>
pub fn to_i32_saturating_round(&self, round: Round) -> Option<i32>
Converts to an i32
, applying the specified rounding method.
If the value is too small or too large for the target type, the minimum
or maximum value allowed is returned. If the value is a NaN, None
is
returned.
§Examples
use rug::float::Round;
use rug::Float;
let f = Float::with_val(53, -13.7);
assert_eq!(f.to_i32_saturating_round(Round::Up), Some(-13));
sourcepub fn to_u32_saturating(&self) -> Option<u32>
pub fn to_u32_saturating(&self) -> Option<u32>
Converts to a u32
, rounding to the nearest.
If the value is too small or too large for the target type, the minimum
or maximum value allowed is returned. If the value is a NaN, None
is
returned.
§Examples
use rug::{Assign, Float};
let mut f = Float::with_val(53, 13.7);
assert_eq!(f.to_u32_saturating(), Some(14));
f.assign(-1);
assert_eq!(f.to_u32_saturating(), Some(0));
f.assign(1e40);
assert_eq!(f.to_u32_saturating(), Some(u32::MAX));
sourcepub fn to_u32_saturating_round(&self, round: Round) -> Option<u32>
pub fn to_u32_saturating_round(&self, round: Round) -> Option<u32>
Converts to a u32
, applying the specified rounding method.
If the value is too small or too large for the target type, the minimum
or maximum value allowed is returned. If the value is a NaN, None
is
returned.
§Examples
use rug::float::Round;
use rug::Float;
let f = Float::with_val(53, 13.7);
assert_eq!(f.to_u32_saturating_round(Round::Down), Some(13));
sourcepub fn to_f32(&self) -> f32
pub fn to_f32(&self) -> f32
Converts to an f32
, rounding to the nearest.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::{Assign, Float};
let mut f = Float::with_val(53, 13.7);
assert_eq!(f.to_f32(), 13.7);
f.assign(1e300);
assert_eq!(f.to_f32(), f32::INFINITY);
f.assign(1e-300);
assert_eq!(f.to_f32(), 0.0);
sourcepub fn to_f32_round(&self, round: Round) -> f32
pub fn to_f32_round(&self, round: Round) -> f32
Converts to an f32
, applying the specified rounding method.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::float::Round;
use rug::Float;
let f = Float::with_val(53, 1.0 + (-50f64).exp2());
assert_eq!(f.to_f32_round(Round::Up), 1.0 + f32::EPSILON);
sourcepub fn to_f64(&self) -> f64
pub fn to_f64(&self) -> f64
Converts to an f64
, rounding to the nearest.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::{Assign, Float};
let mut f = Float::with_val(53, 13.7);
assert_eq!(f.to_f64(), 13.7);
f.assign(1e300);
f.square_mut();
assert_eq!(f.to_f64(), f64::INFINITY);
sourcepub fn to_f64_round(&self, round: Round) -> f64
pub fn to_f64_round(&self, round: Round) -> f64
Converts to an f64
, applying the specified rounding method.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::float::Round;
use rug::Float;
// (2.0 ^ -90) + 1
let f: Float = Float::with_val(100, -90).exp2() + 1;
assert_eq!(f.to_f64_round(Round::Up), 1.0 + f64::EPSILON);
sourcepub fn to_f32_exp(&self) -> (f32, i32)
pub fn to_f32_exp(&self) -> (f32, i32)
Converts to an f32
and an exponent, rounding to the nearest.
The returned f32
is in the range 0.5 ≤ x < 1.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::Float;
let zero = Float::new(64);
let (d0, exp0) = zero.to_f32_exp();
assert_eq!((d0, exp0), (0.0, 0));
let three_eighths = Float::with_val(64, 0.375);
let (d3_8, exp3_8) = three_eighths.to_f32_exp();
assert_eq!((d3_8, exp3_8), (0.75, -1));
sourcepub fn to_f32_exp_round(&self, round: Round) -> (f32, i32)
pub fn to_f32_exp_round(&self, round: Round) -> (f32, i32)
Converts to an f32
and an exponent, applying the specified rounding
method.
The returned f32
is in the range 0.5 ≤ x < 1.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::float::Round;
use rug::Float;
let frac_10_3 = Float::with_val(64, 10) / 3u32;
let (f_down, exp_down) = frac_10_3.to_f32_exp_round(Round::Down);
assert_eq!((f_down, exp_down), (0.8333333, 2));
let (f_up, exp_up) = frac_10_3.to_f32_exp_round(Round::Up);
assert_eq!((f_up, exp_up), (0.8333334, 2));
sourcepub fn to_f64_exp(&self) -> (f64, i32)
pub fn to_f64_exp(&self) -> (f64, i32)
Converts to an f64
and an exponent, rounding to the nearest.
The returned f64
is in the range 0.5 ≤ x < 1.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::Float;
let zero = Float::new(64);
let (d0, exp0) = zero.to_f64_exp();
assert_eq!((d0, exp0), (0.0, 0));
let three_eighths = Float::with_val(64, 0.375);
let (d3_8, exp3_8) = three_eighths.to_f64_exp();
assert_eq!((d3_8, exp3_8), (0.75, -1));
sourcepub fn to_f64_exp_round(&self, round: Round) -> (f64, i32)
pub fn to_f64_exp_round(&self, round: Round) -> (f64, i32)
Converts to an f64
and an exponent, applying the specified rounding
method.
The returned f64
is in the range 0.5 ≤ x < 1.
If the value is too small or too large for the target type, the minimum or maximum value allowed is returned.
§Examples
use rug::float::Round;
use rug::Float;
let frac_10_3 = Float::with_val(64, 10) / 3u32;
let (f_down, exp_down) = frac_10_3.to_f64_exp_round(Round::Down);
assert_eq!((f_down, exp_down), (0.8333333333333333, 2));
let (f_up, exp_up) = frac_10_3.to_f64_exp_round(Round::Up);
assert_eq!((f_up, exp_up), (0.8333333333333334, 2));
sourcepub fn to_string_radix(&self, radix: i32, num_digits: Option<usize>) -> String
Available on crate feature std
only.
pub fn to_string_radix(&self, radix: i32, num_digits: Option<usize>) -> String
std
only.Returns a string representation of self
for the specified radix
rounding to the nearest.
The exponent is encoded in decimal. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.
§Panics
Panics if radix
is less than 2 or greater than 36.
§Examples
use rug::float::Special;
use rug::Float;
let neg_inf = Float::with_val(53, Special::NegInfinity);
assert_eq!(neg_inf.to_string_radix(10, None), "-inf");
assert_eq!(neg_inf.to_string_radix(16, None), "-@inf@");
let twentythree = Float::with_val(8, 23);
assert_eq!(twentythree.to_string_radix(10, None), "23.00");
assert_eq!(twentythree.to_string_radix(16, None), "17.0");
assert_eq!(twentythree.to_string_radix(10, Some(2)), "23");
assert_eq!(twentythree.to_string_radix(16, Some(4)), "17.00");
// 2 raised to the power of 80 in hex is 1 followed by 20 zeros
let two_to_80 = Float::with_val(53, 80f64.exp2());
assert_eq!(two_to_80.to_string_radix(10, Some(3)), "1.21e24");
assert_eq!(two_to_80.to_string_radix(16, Some(3)), "1.00@20");
sourcepub fn to_string_radix_round(
&self,
radix: i32,
num_digits: Option<usize>,
round: Round,
) -> String
Available on crate feature std
only.
pub fn to_string_radix_round( &self, radix: i32, num_digits: Option<usize>, round: Round, ) -> String
std
only.Returns a string representation of self
for the specified radix
applying the specified rounding method.
The exponent is encoded in decimal. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.
§Panics
Panics if radix
is less than 2 or greater than 36.
§Examples
use rug::float::Round;
use rug::Float;
let twentythree = Float::with_val(8, 23.3);
let down = twentythree.to_string_radix_round(10, Some(2), Round::Down);
assert_eq!(down, "23");
let up = twentythree.to_string_radix_round(10, Some(2), Round::Up);
assert_eq!(up, "24");
sourcepub fn to_sign_string_exp(
&self,
radix: i32,
num_digits: Option<usize>,
) -> (bool, String, Option<i32>)
Available on crate feature std
only.
pub fn to_sign_string_exp( &self, radix: i32, num_digits: Option<usize>, ) -> (bool, String, Option<i32>)
std
only.Returns a string representation of self
together with a sign and an
exponent for the specified radix
, rounding to the nearest.
The returned exponent is None
if the Float
is zero, infinite or
NaN, that is if the value is not normal.
For normal values, the returned string has an implicit radix point before the first digit. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.
§Panics
Panics if radix
is less than 2 or greater than 36.
§Examples
use rug::float::Special;
use rug::Float;
let inf = Float::with_val(53, Special::Infinity);
let (sign, s, exp) = inf.to_sign_string_exp(10, None);
assert_eq!((sign, &*s, exp), (false, "inf", None));
let (sign, s, exp) = (-inf).to_sign_string_exp(16, None);
assert_eq!((sign, &*s, exp), (true, "@inf@", None));
let (sign, s, exp) = Float::with_val(8, -0.0625).to_sign_string_exp(10, None);
assert_eq!((sign, &*s, exp), (true, "6250", Some(-1)));
let (sign, s, exp) = Float::with_val(8, -0.625).to_sign_string_exp(10, None);
assert_eq!((sign, &*s, exp), (true, "6250", Some(0)));
let (sign, s, exp) = Float::with_val(8, -6.25).to_sign_string_exp(10, None);
assert_eq!((sign, &*s, exp), (true, "6250", Some(1)));
// -4.8e4 = 48_000, which is rounded to 48_128 using 8 bits of precision
let (sign, s, exp) = Float::with_val(8, -4.8e4).to_sign_string_exp(10, None);
assert_eq!((sign, &*s, exp), (true, "4813", Some(5)));
sourcepub fn to_sign_string_exp_round(
&self,
radix: i32,
num_digits: Option<usize>,
round: Round,
) -> (bool, String, Option<i32>)
Available on crate feature std
only.
pub fn to_sign_string_exp_round( &self, radix: i32, num_digits: Option<usize>, round: Round, ) -> (bool, String, Option<i32>)
std
only.Returns a string representation of self
together with a sign and an
exponent for the specified radix
, applying the specified rounding
method.
The returned exponent is None
if the Float
is zero, infinite or
NaN, that is if the value is not normal.
For normal values, the returned string has an implicit radix point before the first digit. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.
§Panics
Panics if radix
is less than 2 or greater than 36.
§Examples
use rug::float::Round;
use rug::Float;
let val = Float::with_val(53, -0.0625);
// rounding -0.0625 to two significant digits towards -∞ gives -0.063
let (sign, s, exp) = val.to_sign_string_exp_round(10, Some(2), Round::Down);
assert_eq!((sign, &*s, exp), (true, "63", Some(-1)));
// rounding -0.0625 to two significant digits towards +∞ gives -0.062
let (sign, s, exp) = val.to_sign_string_exp_round(10, Some(2), Round::Up);
assert_eq!((sign, &*s, exp), (true, "62", Some(-1)));
let val = Float::with_val(53, 6.25e4);
// rounding 6.25e4 to two significant digits towards -∞ gives 6.2e4
let (sign, s, exp) = val.to_sign_string_exp_round(10, Some(2), Round::Down);
assert_eq!((sign, &*s, exp), (false, "62", Some(5)));
// rounding 6.25e4 to two significant digits towards +∞ gives 6.3e4
let (sign, s, exp) = val.to_sign_string_exp_round(10, Some(2), Round::Up);
assert_eq!((sign, &*s, exp), (false, "63", Some(5)));
sourcepub fn as_neg(&self) -> BorrowFloat<'_>
pub fn as_neg(&self) -> BorrowFloat<'_>
Borrows a negated copy of the Float
.
The returned object implements Deref<Target = Float>
.
This method performs a shallow copy and negates it, and negation does not change the allocated data.
Unlike the other negation methods (the -
operator,
Neg::neg
, etc.), this method does not set the
MPFR NaN flag if a NaN is encountered.
§Examples
use rug::Float;
let f = Float::with_val(53, 4.2);
let neg_f = f.as_neg();
assert_eq!(*neg_f, -4.2);
// methods taking &self can be used on the returned object
let reneg_f = neg_f.as_neg();
assert_eq!(*reneg_f, 4.2);
assert_eq!(*reneg_f, f);
sourcepub fn as_abs(&self) -> BorrowFloat<'_>
pub fn as_abs(&self) -> BorrowFloat<'_>
Borrows an absolute copy of the Float
.
The returned object implements Deref<Target = Float>
.
This method performs a shallow copy and possibly negates it, and negation does not change the allocated data.
Unlike the other absolute value methods (abs
, abs_mut
, etc.),
this method does not set the MPFR NaN flag if a NaN is encountered.
§Examples
use rug::Float;
let f = Float::with_val(53, -4.2);
let abs_f = f.as_abs();
assert_eq!(*abs_f, 4.2);
// methods taking &self can be used on the returned object
let reabs_f = abs_f.as_abs();
assert_eq!(*reabs_f, 4.2);
assert_eq!(*reabs_f, *abs_f);
sourcepub fn as_ord(&self) -> &OrdFloat
pub fn as_ord(&self) -> &OrdFloat
Borrows the Float
as an ordered floating-point number of type
OrdFloat
.
The same result can be obtained using the implementation of
AsRef<OrdFloat>
which is provided for Float
.
§Examples
use core::cmp::Ordering;
use rug::float::Special;
use rug::Float;
let nan_f = Float::with_val(53, Special::Nan);
let nan = nan_f.as_ord();
let neg_nan_f = nan_f.as_neg();
let neg_nan = neg_nan_f.as_ord();
assert_eq!(nan.cmp(nan), Ordering::Equal);
assert_eq!(neg_nan.cmp(nan), Ordering::Less);
let inf_f = Float::with_val(53, Special::Infinity);
let inf = inf_f.as_ord();
let neg_inf_f = Float::with_val(53, Special::NegInfinity);
let neg_inf = neg_inf_f.as_ord();
assert_eq!(nan.cmp(inf), Ordering::Greater);
assert_eq!(neg_nan.cmp(neg_inf), Ordering::Less);
let zero_f = Float::with_val(53, Special::Zero);
let zero = zero_f.as_ord();
let neg_zero_f = Float::with_val(53, Special::NegZero);
let neg_zero = neg_zero_f.as_ord();
assert_eq!(zero.cmp(neg_zero), Ordering::Greater);
sourcepub fn as_complex(&self) -> BorrowComplex<'_>
Available on crate feature complex
only.
pub fn as_complex(&self) -> BorrowComplex<'_>
complex
only.Borrows a copy of the Float
as a Complex
number.
The returned object implements
Deref<Target = Complex>
.
The imaginary part of the return value has the same precision as the real part. While this has no effect for the zero value of the returned complex number, it could have an effect if the return value is cloned.
§Examples
use rug::Float;
let f = Float::with_val(53, 4.2);
let c = f.as_complex();
assert_eq!(*c, (4.2, 0.0));
// methods taking &self can be used on the returned object
let c_mul_i = c.as_mul_i(false);
assert_eq!(*c_mul_i, (0.0, 4.2));
sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
Returns true
if self
is a normal number, that is neither NaN, nor
infinity, nor zero. Note that Float
cannot be subnormal.
§Examples
use rug::float::Special;
use rug::{Assign, Float};
let mut f = Float::with_val(53, Special::Zero);
assert!(!f.is_normal());
f += 5.2;
assert!(f.is_normal());
f.assign(Special::Infinity);
assert!(!f.is_normal());
f.assign(Special::Nan);
assert!(!f.is_normal());
sourcepub fn classify(&self) -> FpCategory
pub fn classify(&self) -> FpCategory
Returns the floating-point category of the number. Note that Float
cannot be subnormal.
§Examples
use core::num::FpCategory;
use rug::float::Special;
use rug::Float;
let nan = Float::with_val(53, Special::Nan);
let infinite = Float::with_val(53, Special::Infinity);
let zero = Float::with_val(53, Special::Zero);
let normal = Float::with_val(53, 2.3);
assert_eq!(nan.classify(), FpCategory::Nan);
assert_eq!(infinite.classify(), FpCategory::Infinite);
assert_eq!(zero.classify(), FpCategory::Zero);
assert_eq!(normal.classify(), FpCategory::Normal);
sourcepub fn cmp0(&self) -> Option<Ordering>
pub fn cmp0(&self) -> Option<Ordering>
Returns the same result as
self.partial_cmp(&0)
, but is
faster.
§Examples
use core::cmp::Ordering;
use rug::float::Special;
use rug::{Assign, Float};
let mut f = Float::with_val(53, Special::NegZero);
assert_eq!(f.cmp0(), Some(Ordering::Equal));
f += 5.2;
assert_eq!(f.cmp0(), Some(Ordering::Greater));
f.assign(Special::NegInfinity);
assert_eq!(f.cmp0(), Some(Ordering::Less));
f.assign(Special::Nan);
assert_eq!(f.cmp0(), None);
sourcepub fn cmp_abs(&self, other: &Float) -> Option<Ordering>
pub fn cmp_abs(&self, other: &Float) -> Option<Ordering>
Compares the absolute values of self
and other
.
§Examples
use core::cmp::Ordering;
use rug::Float;
let a = Float::with_val(53, -10);
let b = Float::with_val(53, 4);
assert_eq!(a.partial_cmp(&b), Some(Ordering::Less));
assert_eq!(a.cmp_abs(&b), Some(Ordering::Greater));
sourcepub fn total_cmp(&self, other: &Float) -> Ordering
pub fn total_cmp(&self, other: &Float) -> Ordering
Returns the total ordering between self
and other
.
Negative zero is ordered as less than positive zero. Negative NaN is ordered as less than negative infinity, while positive NaN is ordered as greater than positive infinity. Comparing two negative NaNs or two positive NaNs produces equality.
§Examples
use rug::float::Special;
use rug::Float;
let mut values = vec![
Float::with_val(53, Special::Zero),
Float::with_val(53, Special::NegZero),
Float::with_val(53, Special::Infinity),
Float::with_val(53, Special::NegInfinity),
Float::with_val(53, Special::Nan),
-Float::with_val(53, Special::Nan),
];
values.sort_by(Float::total_cmp);
// NaN with negative sign
assert!(values[0].is_nan() && values[0].is_sign_negative());
// -∞
assert!(values[1].is_infinite() && values[1].is_sign_negative());
// -0
assert!(values[2].is_zero() && values[2].is_sign_negative());
// +0
assert!(values[3].is_zero() && values[3].is_sign_positive());
// +∞
assert!(values[4].is_infinite() && values[4].is_sign_positive());
// NaN with positive sign
assert!(values[5].is_nan() && values[5].is_sign_positive());
sourcepub fn get_exp(&self) -> Option<i32>
pub fn get_exp(&self) -> Option<i32>
If the value is a normal number, returns its exponent.
The significand is assumed to be in the range 0.5 ≤ x < 1.
§Examples
use rug::{Assign, Float};
// -(2.0 ^ 32) == -(0.5 × 2 ^ 33)
let mut f = Float::with_val(53, -32f64.exp2());
assert_eq!(f.get_exp(), Some(33));
// 0.8 × 2 ^ -39
f.assign(0.8 * (-39f64).exp2());
assert_eq!(f.get_exp(), Some(-39));
f.assign(0);
assert_eq!(f.get_exp(), None);
sourcepub fn get_significand(&self) -> Option<BorrowInteger<'_>>
Available on crate feature integer
only.
pub fn get_significand(&self) -> Option<BorrowInteger<'_>>
integer
only.If the value is a normal number, returns a reference
to its significand as an Integer
.
The unwrapped returned object implements
Deref<Target = Integer>
.
The number of significant bits of a returned significand is at least
equal to the precision, but can be larger. It is usually
rounded up to a multiple of 32 or 64 depending on the implementation; in
this case, the extra least significant bits will be zero. The value of
self
is exactly equal to the returned Integer
divided by two
raised to the power of the number of significant bits and multiplied
by two raised to the power of the exponent of self
.
Unlike the to_integer_exp
method which
returns an owned Integer
, this method only performs a shallow copy
and does not allocate any memory.
§Examples
use rug::Float;
let float = Float::with_val(16, 6.5);
// 6.5 in binary is 110.1 = 0.1101 times two to the power of 3
let exp = float.get_exp().unwrap();
assert_eq!(exp, 3);
let significand = float.get_significand().unwrap();
let sig_bits = significand.significant_bits();
// sig_bits must be greater or equal to precision
assert!(sig_bits >= 16);
let (check_int, check_exp) = float.to_integer_exp().unwrap();
assert_eq!(check_int << sig_bits << (check_exp - exp), *significand);
sourcepub fn is_sign_positive(&self) -> bool
pub fn is_sign_positive(&self) -> bool
sourcepub fn is_sign_negative(&self) -> bool
pub fn is_sign_negative(&self) -> bool
sourcepub fn remainder_ref<'a>(
&'a self,
divisor: &'a Float,
) -> RemainderIncomplete<'a>
pub fn remainder_ref<'a>( &'a self, divisor: &'a Float, ) -> RemainderIncomplete<'a>
Computes the remainder.
The remainder is the value of
self
− n × divisor
, where n
is the integer quotient of self
/ divisor
rounded to the
nearest integer (ties rounded to even). This is different from the
remainder obtained using the %
operator or the Rem
trait, where n is truncated instead of rounded to the nearest.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 589.4);
let g = Float::with_val(53, 100);
let remainder = Float::with_val(53, f.remainder_ref(&g));
let expected = -10.6_f64;
assert!((remainder - expected).abs() < 0.0001);
// compare to % operator
let f = Float::with_val(53, 589.4);
let g = Float::with_val(53, 100);
let rem_op = Float::with_val(53, &f % &g);
let expected = 89.4_f64;
assert!((rem_op - expected).abs() < 0.0001);
sourcepub fn mul_add_ref<'a>(
&'a self,
mul: &'a Float,
add: &'a Float,
) -> AddMulIncomplete<'a>
pub fn mul_add_ref<'a>( &'a self, mul: &'a Float, add: &'a Float, ) -> AddMulIncomplete<'a>
Multiplies and adds in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
a.mul_add_ref(&b, &c)
produces the exact same result as &a * &b + &c
.
§Examples
use rug::Float;
// Use only 4 bits of precision for demonstration purposes.
// 1.5 in binary is 1.1.
let mul1 = Float::with_val(4, 1.5);
// -13 in binary is -1101.
let mul2 = Float::with_val(4, -13);
// 24 in binary is 11000.
let add = Float::with_val(4, 24);
// 1.5 × -13 + 24 = 4.5
let ans = Float::with_val(4, mul1.mul_add_ref(&mul2, &add));
assert_eq!(ans, 4.5);
sourcepub fn mul_sub_ref<'a>(
&'a self,
mul: &'a Float,
sub: &'a Float,
) -> SubMulFromIncomplete<'a>
pub fn mul_sub_ref<'a>( &'a self, mul: &'a Float, sub: &'a Float, ) -> SubMulFromIncomplete<'a>
Multiplies and subtracts in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
a.mul_sub_ref(&b, &c)
produces the exact same result as &a * &b - &c
.
§Examples
use rug::Float;
// Use only 4 bits of precision for demonstration purposes.
// 1.5 in binary is 1.1.
let mul1 = Float::with_val(4, 1.5);
// -13 in binary is -1101.
let mul2 = Float::with_val(4, -13);
// 24 in binary is 11000.
let sub = Float::with_val(4, 24);
// 1.5 × -13 - 24 = -43.5, rounded to 44 using four bits of precision.
let ans = Float::with_val(4, mul1.mul_sub_ref(&mul2, &sub));
assert_eq!(ans, -44);
sourcepub fn mul_add_mul_ref<'a>(
&'a self,
mul: &'a Float,
add_mul1: &'a Float,
add_mul2: &'a Float,
) -> MulAddMulIncomplete<'a>
pub fn mul_add_mul_ref<'a>( &'a self, mul: &'a Float, add_mul1: &'a Float, add_mul2: &'a Float, ) -> MulAddMulIncomplete<'a>
Multiplies two products and adds them in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
a.mul_add_mul_ref(&b, &c, &d)
produces the exact same result
as &a * &b + &c * &d
.
§Examples
use rug::Float;
let a = Float::with_val(53, 24);
let b = Float::with_val(53, 1.5);
let c = Float::with_val(53, 12);
let d = Float::with_val(53, 2);
// 24 × 1.5 + 12 × 2 = 60
let ans = Float::with_val(53, a.mul_add_mul_ref(&b, &c, &d));
assert_eq!(ans, 60);
sourcepub fn mul_sub_mul_ref<'a>(
&'a self,
mul: &'a Float,
sub_mul1: &'a Float,
sub_mul2: &'a Float,
) -> MulSubMulIncomplete<'a>
pub fn mul_sub_mul_ref<'a>( &'a self, mul: &'a Float, sub_mul1: &'a Float, sub_mul2: &'a Float, ) -> MulSubMulIncomplete<'a>
Multiplies two products and subtracts them in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
a.mul_sub_mul_ref(&b, &c, &d)
produces the exact same result as &a * &b - &c * &d
.
§Examples
use rug::Float;
let a = Float::with_val(53, 24);
let b = Float::with_val(53, 1.5);
let c = Float::with_val(53, 12);
let d = Float::with_val(53, 2);
// 24 × 1.5 - 12 × 2 = 12
let ans = Float::with_val(53, a.mul_sub_mul_ref(&b, &c, &d));
assert_eq!(ans, 12);
sourcepub fn square_ref(&self) -> SquareIncomplete<'_>
pub fn square_ref(&self) -> SquareIncomplete<'_>
Computes the square.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 5.0);
let r = f.square_ref();
let square = Float::with_val(53, r);
assert_eq!(square, 25.0);
sourcepub fn sqrt_ref(&self) -> SqrtIncomplete<'_>
pub fn sqrt_ref(&self) -> SqrtIncomplete<'_>
Computes the square root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 25.0);
let r = f.sqrt_ref();
let sqrt = Float::with_val(53, r);
assert_eq!(sqrt, 5.0);
sourcepub fn recip_sqrt_ref(&self) -> RecipSqrtIncomplete<'_>
pub fn recip_sqrt_ref(&self) -> RecipSqrtIncomplete<'_>
Computes the reciprocal square root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 16.0);
let r = f.recip_sqrt_ref();
let recip_sqrt = Float::with_val(53, r);
assert_eq!(recip_sqrt, 0.25);
sourcepub fn cbrt_ref(&self) -> CbrtIncomplete<'_>
pub fn cbrt_ref(&self) -> CbrtIncomplete<'_>
Computes the cube root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 125.0);
let r = f.cbrt_ref();
let cbrt = Float::with_val(53, r);
assert_eq!(cbrt, 5.0);
sourcepub fn root_ref(&self, k: u32) -> RootIncomplete<'_>
pub fn root_ref(&self, k: u32) -> RootIncomplete<'_>
Computes the kth root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 625.0);
let r = f.root_ref(4);
let root = Float::with_val(53, r);
assert_eq!(root, 5.0);
sourcepub fn root_i_ref(&self, k: i32) -> RootIIncomplete<'_>
pub fn root_i_ref(&self, k: i32) -> RootIIncomplete<'_>
Computes the kth root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 625.0);
let r = f.root_i_ref(-4);
let root_i = Float::with_val(53, r);
let expected = 0.2000_f64;
assert!((root_i - expected).abs() < 0.0001);
sourcepub fn abs_ref(&self) -> AbsIncomplete<'_>
pub fn abs_ref(&self) -> AbsIncomplete<'_>
Computes the absolute value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -23.5);
let r = f.abs_ref();
let abs = Float::with_val(53, r);
assert_eq!(abs, 23.5);
sourcepub fn signum_ref(&self) -> SignumIncomplete<'_>
pub fn signum_ref(&self) -> SignumIncomplete<'_>
Computes the signum.
- 1.0 if the value is positive, +0.0 or +∞
- −1.0 if the value is negative, −0.0 or −∞
- NaN if the value is NaN
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -23.5);
let r = f.signum_ref();
let signum = Float::with_val(53, r);
assert_eq!(signum, -1);
sourcepub fn copysign_ref<'a>(&'a self, y: &'a Float) -> CopysignIncomplete<'a>
pub fn copysign_ref<'a>(&'a self, y: &'a Float) -> CopysignIncomplete<'a>
Computes a number with the magnitude of self
and the sign of y
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let x = Float::with_val(53, 23.0);
let y = Float::with_val(53, -1.0);
let r = x.copysign_ref(&y);
let copysign = Float::with_val(53, r);
assert_eq!(copysign, -23.0);
sourcepub fn clamp_ref<'min, 'max, Min, Max>(
&self,
min: &'min Min,
max: &'max Max,
) -> ClampIncomplete<'_, 'min, 'max, Min, Max>where
Float: PartialOrd<Min> + PartialOrd<Max> + for<'a> AssignRound<&'a Min, Round = Round, Ordering = Ordering, Round = Round, Ordering = Ordering> + for<'a> AssignRound<&'a Max>,
pub fn clamp_ref<'min, 'max, Min, Max>(
&self,
min: &'min Min,
max: &'max Max,
) -> ClampIncomplete<'_, 'min, 'max, Min, Max>where
Float: PartialOrd<Min> + PartialOrd<Max> + for<'a> AssignRound<&'a Min, Round = Round, Ordering = Ordering, Round = Round, Ordering = Ordering> + for<'a> AssignRound<&'a Max>,
Clamps the value within the specified bounds.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Panics
Panics if the maximum value is less than the minimum value, unless assigning any of them to the target produces the same value with the same rounding direction.
§Examples
use rug::Float;
let min = -1.5;
let max = 1.5;
let too_small = Float::with_val(53, -2.5);
let r1 = too_small.clamp_ref(&min, &max);
let clamped1 = Float::with_val(53, r1);
assert_eq!(clamped1, -1.5);
let in_range = Float::with_val(53, 0.5);
let r2 = in_range.clamp_ref(&min, &max);
let clamped2 = Float::with_val(53, r2);
assert_eq!(clamped2, 0.5);
sourcepub fn recip_ref(&self) -> RecipIncomplete<'_>
pub fn recip_ref(&self) -> RecipIncomplete<'_>
Computes the reciprocal.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.25);
let r = f.recip_ref();
let recip = Float::with_val(53, r);
assert_eq!(recip, -4.0);
sourcepub fn min_ref<'a>(&'a self, other: &'a Float) -> MinIncomplete<'a>
pub fn min_ref<'a>(&'a self, other: &'a Float) -> MinIncomplete<'a>
Finds the minimum.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let a = Float::with_val(53, 5.2);
let b = Float::with_val(53, -2);
let r = a.min_ref(&b);
let min = Float::with_val(53, r);
assert_eq!(min, -2);
sourcepub fn max_ref<'a>(&'a self, other: &'a Float) -> MaxIncomplete<'a>
pub fn max_ref<'a>(&'a self, other: &'a Float) -> MaxIncomplete<'a>
Finds the maximum.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let a = Float::with_val(53, 5.2);
let b = Float::with_val(53, 12.5);
let r = a.max_ref(&b);
let max = Float::with_val(53, r);
assert_eq!(max, 12.5);
sourcepub fn positive_diff_ref<'a>(
&'a self,
other: &'a Float,
) -> PositiveDiffIncomplete<'a>
pub fn positive_diff_ref<'a>( &'a self, other: &'a Float, ) -> PositiveDiffIncomplete<'a>
Computes the positive difference.
The positive difference is self
− other
if self
> other
, zero if
self
≤ other
, or NaN if any operand is NaN.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let a = Float::with_val(53, 12.5);
let b = Float::with_val(53, 7.3);
let rab = a.positive_diff_ref(&b);
let ab = Float::with_val(53, rab);
assert_eq!(ab, 5.2);
let rba = b.positive_diff_ref(&a);
let ba = Float::with_val(53, rba);
assert_eq!(ba, 0);
sourcepub fn ln_ref(&self) -> LnIncomplete<'_>
pub fn ln_ref(&self) -> LnIncomplete<'_>
Computes the natural logarithm.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let ln = Float::with_val(53, f.ln_ref());
let expected = 0.4055_f64;
assert!((ln - expected).abs() < 0.0001);
sourcepub fn log2_ref(&self) -> Log2Incomplete<'_>
pub fn log2_ref(&self) -> Log2Incomplete<'_>
Computes the logarithm to base 2.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let log2 = Float::with_val(53, f.log2_ref());
let expected = 0.5850_f64;
assert!((log2 - expected).abs() < 0.0001);
sourcepub fn log10_ref(&self) -> Log10Incomplete<'_>
pub fn log10_ref(&self) -> Log10Incomplete<'_>
Computes the logarithm to base 10.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let log10 = Float::with_val(53, f.log10_ref());
let expected = 0.1761_f64;
assert!((log10 - expected).abs() < 0.0001);
sourcepub fn exp_ref(&self) -> ExpIncomplete<'_>
pub fn exp_ref(&self) -> ExpIncomplete<'_>
Computes the exponential.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let exp = Float::with_val(53, f.exp_ref());
let expected = 4.4817_f64;
assert!((exp - expected).abs() < 0.0001);
sourcepub fn exp2_ref(&self) -> Exp2Incomplete<'_>
pub fn exp2_ref(&self) -> Exp2Incomplete<'_>
Computes 2 to the power of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let exp2 = Float::with_val(53, f.exp2_ref());
let expected = 2.8284_f64;
assert!((exp2 - expected).abs() < 0.0001);
sourcepub fn exp10_ref(&self) -> Exp10Incomplete<'_>
pub fn exp10_ref(&self) -> Exp10Incomplete<'_>
Computes 10 to the power of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.5);
let exp10 = Float::with_val(53, f.exp10_ref());
let expected = 31.6228_f64;
assert!((exp10 - expected).abs() < 0.0001);
sourcepub fn sin_ref(&self) -> SinIncomplete<'_>
pub fn sin_ref(&self) -> SinIncomplete<'_>
Computes the sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let sin = Float::with_val(53, f.sin_ref());
let expected = 0.9490_f64;
assert!((sin - expected).abs() < 0.0001);
sourcepub fn cos_ref(&self) -> CosIncomplete<'_>
pub fn cos_ref(&self) -> CosIncomplete<'_>
Computes the cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let cos = Float::with_val(53, f.cos_ref());
let expected = 0.3153_f64;
assert!((cos - expected).abs() < 0.0001);
sourcepub fn tan_ref(&self) -> TanIncomplete<'_>
pub fn tan_ref(&self) -> TanIncomplete<'_>
Computes the tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let tan = Float::with_val(53, f.tan_ref());
let expected = 3.0096_f64;
assert!((tan - expected).abs() < 0.0001);
sourcepub fn sin_cos_ref(&self) -> SinCosIncomplete<'_>
pub fn sin_cos_ref(&self) -> SinCosIncomplete<'_>
Computes the sine and cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for (Float, Float)
Assign<Src> for (&mut Float, &mut Float)
AssignRound<Src> for (Float, Float)
AssignRound<Src> for (&mut Float, &mut Float)
CompleteRound<Completed = (Float, Float)> for Src
§Examples
use core::cmp::Ordering;
use rug::float::Round;
use rug::ops::AssignRound;
use rug::{Assign, Float};
let phase = Float::with_val(53, 1.25);
let (mut sin, mut cos) = (Float::new(53), Float::new(53));
let sin_cos = phase.sin_cos_ref();
(&mut sin, &mut cos).assign(sin_cos);
let expected_sin = 0.9490_f64;
let expected_cos = 0.3153_f64;
assert!((sin - expected_sin).abs() < 0.0001);
assert!((cos - expected_cos).abs() < 0.0001);
// using 4 significant bits: sin = 0.9375
// using 4 significant bits: cos = 0.3125
let (mut sin_4, mut cos_4) = (Float::new(4), Float::new(4));
let sin_cos = phase.sin_cos_ref();
let (dir_sin, dir_cos) = (&mut sin_4, &mut cos_4)
.assign_round(sin_cos, Round::Nearest);
assert_eq!(sin_4, 0.9375);
assert_eq!(dir_sin, Ordering::Less);
assert_eq!(cos_4, 0.3125);
assert_eq!(dir_cos, Ordering::Less);
sourcepub fn sin_u_ref(&self, u: u32) -> SinUIncomplete<'_>
pub fn sin_u_ref(&self, u: u32) -> SinUIncomplete<'_>
Computes the sine of (2π/u) × self
.
For example, if u = 360, then this is the sine for
self
in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 60);
let sin = Float::with_val(53, f.sin_u_ref(360));
let expected = 0.75_f64.sqrt();
assert!((sin - expected).abs() < 0.0001);
sourcepub fn cos_u_ref(&self, u: u32) -> CosUIncomplete<'_>
pub fn cos_u_ref(&self, u: u32) -> CosUIncomplete<'_>
Computes the cosine of (2π/u) × self
.
For example, if u = 360, then this is the cosine for
self
in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 30);
let cos = Float::with_val(53, f.cos_u_ref(360));
let expected = 0.75_f64.sqrt();
assert!((cos - expected).abs() < 0.0001);
sourcepub fn tan_u_ref(&self, u: u32) -> TanUIncomplete<'_>
pub fn tan_u_ref(&self, u: u32) -> TanUIncomplete<'_>
Computes the tangent of (2π/u) × self
.
For example, if u = 360, then this is the tangent for
self
in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 60);
let tan = Float::with_val(53, f.tan_u_ref(360));
let expected = 3_f64.sqrt();
assert!((tan - expected).abs() < 0.0001);
sourcepub fn sin_pi_ref(&self) -> SinPiIncomplete<'_>
pub fn sin_pi_ref(&self) -> SinPiIncomplete<'_>
Computes the sine of π × self
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 0.25);
let sin = Float::with_val(53, f.sin_pi_ref());
let expected = 0.5_f64.sqrt();
assert!((sin - expected).abs() < 0.0001);
sourcepub fn cos_pi_ref(&self) -> CosPiIncomplete<'_>
pub fn cos_pi_ref(&self) -> CosPiIncomplete<'_>
Computes the cosine of π × self
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 0.25);
let cos = Float::with_val(53, f.cos_pi_ref());
let expected = 0.5_f64.sqrt();
assert!((cos - expected).abs() < 0.0001);
sourcepub fn tan_pi_ref(&self) -> TanPiIncomplete<'_>
pub fn tan_pi_ref(&self) -> TanPiIncomplete<'_>
Computes the tangent of π × self
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 0.125);
let tan = Float::with_val(53, f.tan_pi_ref());
let expected = 0.4142_f64;
assert!((tan - expected).abs() < 0.0001);
sourcepub fn sec_ref(&self) -> SecIncomplete<'_>
pub fn sec_ref(&self) -> SecIncomplete<'_>
Computes the secant.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let sec = Float::with_val(53, f.sec_ref());
let expected = 3.1714_f64;
assert!((sec - expected).abs() < 0.0001);
sourcepub fn csc_ref(&self) -> CscIncomplete<'_>
pub fn csc_ref(&self) -> CscIncomplete<'_>
Computes the cosecant.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let csc = Float::with_val(53, f.csc_ref());
let expected = 1.0538_f64;
assert!((csc - expected).abs() < 0.0001);
sourcepub fn cot_ref(&self) -> CotIncomplete<'_>
pub fn cot_ref(&self) -> CotIncomplete<'_>
Computes the cotangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let cot = Float::with_val(53, f.cot_ref());
let expected = 0.3323_f64;
assert!((cot - expected).abs() < 0.0001);
sourcepub fn asin_ref(&self) -> AsinIncomplete<'_>
pub fn asin_ref(&self) -> AsinIncomplete<'_>
Computes the arc-sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let asin = Float::with_val(53, f.asin_ref());
let expected = -0.8481_f64;
assert!((asin - expected).abs() < 0.0001);
sourcepub fn acos_ref(&self) -> AcosIncomplete<'_>
pub fn acos_ref(&self) -> AcosIncomplete<'_>
Computes the arc-cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let acos = Float::with_val(53, f.acos_ref());
let expected = 2.4189_f64;
assert!((acos - expected).abs() < 0.0001);
sourcepub fn atan_ref(&self) -> AtanIncomplete<'_>
pub fn atan_ref(&self) -> AtanIncomplete<'_>
Computes the arc-tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let atan = Float::with_val(53, f.atan_ref());
let expected = -0.6435_f64;
assert!((atan - expected).abs() < 0.0001);
sourcepub fn atan2_ref<'a>(&'a self, x: &'a Float) -> Atan2Incomplete<'a>
pub fn atan2_ref<'a>(&'a self, x: &'a Float) -> Atan2Incomplete<'a>
Computes the arc-tangent2.
This is similar to the arc-tangent of self / x
, but has an output
range of 2π rather than π.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let y = Float::with_val(53, 3.0);
let x = Float::with_val(53, -4.0);
let r = y.atan2_ref(&x);
let atan2 = Float::with_val(53, r);
let expected = 2.4981_f64;
assert!((atan2 - expected).abs() < 0.0001);
sourcepub fn asin_u_ref(&self, u: u32) -> AsinUIncomplete<'_>
pub fn asin_u_ref(&self, u: u32) -> AsinUIncomplete<'_>
Computes the arc-sine then divides by 2π/u.
For example, if u = 360, then this is the arc-sine in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let asin = Float::with_val(53, f.asin_u_ref(360));
let expected = -48.5904_f64;
assert!((asin - expected).abs() < 0.0001);
sourcepub fn acos_u_ref(&self, u: u32) -> AcosUIncomplete<'_>
pub fn acos_u_ref(&self, u: u32) -> AcosUIncomplete<'_>
Computes the arc-cosine then divides by 2π/u.
For example, if u = 360, then this is the arc-cosine in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let acos = Float::with_val(53, f.acos_u_ref(360));
let expected = 138.5904_f64;
assert!((acos - expected).abs() < 0.0001);
sourcepub fn atan_u_ref(&self, u: u32) -> AtanUIncomplete<'_>
pub fn atan_u_ref(&self, u: u32) -> AtanUIncomplete<'_>
Computes the arc-tangent then divides by 2π/u.
For example, if u = 360, then this is the arc-tangent in degrees.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let atan = Float::with_val(53, f.atan_u_ref(360));
let expected = -36.8699_f64;
assert!((atan - expected).abs() < 0.0001);
sourcepub fn atan2_u_ref<'a>(&'a self, x: &'a Float, u: u32) -> Atan2UIncomplete<'a>
pub fn atan2_u_ref<'a>(&'a self, x: &'a Float, u: u32) -> Atan2UIncomplete<'a>
Computes the arc-tangent2 then divides by 2π/u.
For example, if u = 360, then this is the arc-tangent in degrees.
This is similar to the arc-tangent of self / x
, but has an output
range of u rather than u/2.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let y = Float::with_val(53, 3.0);
let x = Float::with_val(53, -4.0);
let r = y.atan2_u_ref(&x, 360);
let atan2 = Float::with_val(53, r);
let expected = 143.1301_f64;
assert!((atan2 - expected).abs() < 0.0001);
sourcepub fn asin_pi_ref(&self) -> AsinPiIncomplete<'_>
pub fn asin_pi_ref(&self) -> AsinPiIncomplete<'_>
Computes the arc-sine then divides by π.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let asin = Float::with_val(53, f.asin_pi_ref());
let expected = -0.2699_f64;
assert!((asin - expected).abs() < 0.0001);
sourcepub fn acos_pi_ref(&self) -> AcosPiIncomplete<'_>
pub fn acos_pi_ref(&self) -> AcosPiIncomplete<'_>
Computes the arc-cosine then divides by π.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let acos = Float::with_val(53, f.acos_pi_ref());
let expected = 0.7699_f64;
assert!((acos - expected).abs() < 0.0001);
sourcepub fn atan_pi_ref(&self) -> AtanPiIncomplete<'_>
pub fn atan_pi_ref(&self) -> AtanPiIncomplete<'_>
Computes the arc-tangent then divides by π.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, -0.75);
let atan = Float::with_val(53, f.atan_pi_ref());
let expected = -0.2048_f64;
assert!((atan - expected).abs() < 0.0001);
sourcepub fn atan2_pi_ref<'a>(&'a self, x: &'a Float) -> Atan2PiIncomplete<'a>
pub fn atan2_pi_ref<'a>(&'a self, x: &'a Float) -> Atan2PiIncomplete<'a>
Computes the arc-tangent2 then divides by π.
This is similar to the arc-tangent of self / x
, but has an output
range of 2 rather than 1.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let y = Float::with_val(53, 3.0);
let x = Float::with_val(53, -4.0);
let r = y.atan2_pi_ref(&x);
let atan2 = Float::with_val(53, r);
let expected = 0.7952_f64;
assert!((atan2 - expected).abs() < 0.0001);
sourcepub fn sinh_ref(&self) -> SinhIncomplete<'_>
pub fn sinh_ref(&self) -> SinhIncomplete<'_>
Computes the hyperbolic sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let sinh = Float::with_val(53, f.sinh_ref());
let expected = 1.6019_f64;
assert!((sinh - expected).abs() < 0.0001);
sourcepub fn cosh_ref(&self) -> CoshIncomplete<'_>
pub fn cosh_ref(&self) -> CoshIncomplete<'_>
Computes the hyperbolic cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let cosh = Float::with_val(53, f.cosh_ref());
let expected = 1.8884_f64;
assert!((cosh - expected).abs() < 0.0001);
sourcepub fn tanh_ref(&self) -> TanhIncomplete<'_>
pub fn tanh_ref(&self) -> TanhIncomplete<'_>
Computes the hyperbolic tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let tanh = Float::with_val(53, f.tanh_ref());
let expected = 0.8483_f64;
assert!((tanh - expected).abs() < 0.0001);
sourcepub fn sinh_cosh_ref(&self) -> SinhCoshIncomplete<'_>
pub fn sinh_cosh_ref(&self) -> SinhCoshIncomplete<'_>
Computes the hyperbolic sine and cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for (Float, Float)
Assign<Src> for (&mut Float, &mut Float)
AssignRound<Src> for (Float, Float)
AssignRound<Src> for (&mut Float, &mut Float)
CompleteRound<Completed = (Float, Float)> for Src
§Examples
use core::cmp::Ordering;
use rug::float::Round;
use rug::ops::AssignRound;
use rug::{Assign, Float};
let phase = Float::with_val(53, 1.25);
let (mut sinh, mut cosh) = (Float::new(53), Float::new(53));
let sinh_cosh = phase.sinh_cosh_ref();
(&mut sinh, &mut cosh).assign(sinh_cosh);
let expected_sinh = 1.6019_f64;
let expected_cosh = 1.8884_f64;
assert!((sinh - expected_sinh).abs() < 0.0001);
assert!((cosh - expected_cosh).abs() < 0.0001);
// using 4 significant bits: sin = 1.625
// using 4 significant bits: cos = 1.875
let (mut sinh_4, mut cosh_4) = (Float::new(4), Float::new(4));
let sinh_cosh = phase.sinh_cosh_ref();
let (dir_sinh, dir_cosh) = (&mut sinh_4, &mut cosh_4)
.assign_round(sinh_cosh, Round::Nearest);
assert_eq!(sinh_4, 1.625);
assert_eq!(dir_sinh, Ordering::Greater);
assert_eq!(cosh_4, 1.875);
assert_eq!(dir_cosh, Ordering::Less);
sourcepub fn sech_ref(&self) -> SechIncomplete<'_>
pub fn sech_ref(&self) -> SechIncomplete<'_>
Computes the hyperbolic secant.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let sech = Float::with_val(53, f.sech_ref());
let expected = 0.5295_f64;
assert!((sech - expected).abs() < 0.0001);
sourcepub fn csch_ref(&self) -> CschIncomplete<'_>
pub fn csch_ref(&self) -> CschIncomplete<'_>
Computes the hyperbolic cosecant.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let csch = Float::with_val(53, f.csch_ref());
let expected = 0.6243_f64;
assert!((csch - expected).abs() < 0.0001);
sourcepub fn coth_ref(&self) -> CothIncomplete<'_>
pub fn coth_ref(&self) -> CothIncomplete<'_>
Computes the hyperbolic cotangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let coth = Float::with_val(53, f.coth_ref());
let expected = 1.1789_f64;
assert!((coth - expected).abs() < 0.0001);
sourcepub fn asinh_ref(&self) -> AsinhIncomplete<'_>
pub fn asinh_ref(&self) -> AsinhIncomplete<'_>
Computes the inverse hyperbolic sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let asinh = Float::with_val(53, f.asinh_ref());
let expected = 1.0476_f64;
assert!((asinh - expected).abs() < 0.0001);
sourcepub fn acosh_ref(&self) -> AcoshIncomplete<'_>
pub fn acosh_ref(&self) -> AcoshIncomplete<'_>
Computes the inverse hyperbolic cosine
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let acosh = Float::with_val(53, f.acosh_ref());
let expected = 0.6931_f64;
assert!((acosh - expected).abs() < 0.0001);
sourcepub fn atanh_ref(&self) -> AtanhIncomplete<'_>
pub fn atanh_ref(&self) -> AtanhIncomplete<'_>
Computes the inverse hyperbolic tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 0.75);
let atanh = Float::with_val(53, f.atanh_ref());
let expected = 0.9730_f64;
assert!((atanh - expected).abs() < 0.0001);
sourcepub fn ln_1p_ref(&self) -> Ln1pIncomplete<'_>
pub fn ln_1p_ref(&self) -> Ln1pIncomplete<'_>
Computes the natural logorithm of one plus the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let ln_1p = Float::with_val(53, f.ln_1p_ref());
let expected = 1.4989_f64 * two_to_m10;
assert!((ln_1p - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn log2_1p_ref(&self) -> LogTwo1pIncomplete<'_>
pub fn log2_1p_ref(&self) -> LogTwo1pIncomplete<'_>
Computes the logorithm to base 2 of one plus the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let log2_1p = Float::with_val(53, f.log2_1p_ref());
let expected = 2.1625_f64 * two_to_m10;
assert!((log2_1p - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn log10_1p_ref(&self) -> LogTen1pIncomplete<'_>
pub fn log10_1p_ref(&self) -> LogTen1pIncomplete<'_>
Computes the logorithm to base 10 of one plus the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let log10_1p = Float::with_val(53, f.log10_1p_ref());
let expected = 0.6510_f64 * two_to_m10;
assert!((log10_1p - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn exp_m1_ref(&self) -> ExpM1Incomplete<'_>
pub fn exp_m1_ref(&self) -> ExpM1Incomplete<'_>
Computes one less than the exponential of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let exp_m1 = Float::with_val(53, f.exp_m1_ref());
let expected = 1.5011_f64 * two_to_m10;
assert!((exp_m1 - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn exp2_m1_ref(&self) -> Exp2M1Incomplete<'_>
pub fn exp2_m1_ref(&self) -> Exp2M1Incomplete<'_>
Computes one less than 2 to the power of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let exp2_m1 = Float::with_val(53, f.exp2_m1_ref());
let expected = 1.0402_f64 * two_to_m10;
assert!((exp2_m1 - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn exp10_m1_ref(&self) -> Exp10M1Incomplete<'_>
pub fn exp10_m1_ref(&self) -> Exp10M1Incomplete<'_>
Computes one less than 10 to the power of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let exp10_m1 = Float::with_val(53, f.exp10_m1_ref());
let expected = 3.4597_f64 * two_to_m10;
assert!((exp10_m1 - expected).abs() < 0.0001 * two_to_m10);
sourcepub fn compound_i_ref(&self, n: i32) -> CompoundIIncomplete<'_>
pub fn compound_i_ref(&self, n: i32) -> CompoundIIncomplete<'_>
Computes (1 + self
) to the power of n
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let two_to_m10 = (-10f64).exp2();
let f = Float::with_val(53, 1.5 * two_to_m10);
let compound = Float::with_val(53, f.compound_i_ref(100));
let expected = 1.1576_f64;
assert!((compound - expected).abs() < 0.0001);
sourcepub fn eint_ref(&self) -> EintIncomplete<'_>
pub fn eint_ref(&self) -> EintIncomplete<'_>
Computes the exponential integral.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let eint = Float::with_val(53, f.eint_ref());
let expected = 2.5810_f64;
assert!((eint - expected).abs() < 0.0001);
sourcepub fn li2_ref(&self) -> Li2Incomplete<'_>
pub fn li2_ref(&self) -> Li2Incomplete<'_>
Computes the real part of the dilogarithm of the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let li2 = Float::with_val(53, f.li2_ref());
let expected = 2.1902_f64;
assert!((li2 - expected).abs() < 0.0001);
sourcepub fn gamma_ref(&self) -> GammaIncomplete<'_>
pub fn gamma_ref(&self) -> GammaIncomplete<'_>
Computes the gamma function on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let gamma = Float::with_val(53, f.gamma_ref());
let expected = 0.9064_f64;
assert!((gamma - expected).abs() < 0.0001);
sourcepub fn gamma_inc_ref<'a>(&'a self, x: &'a Float) -> GammaIncIncomplete<'a>
pub fn gamma_inc_ref<'a>(&'a self, x: &'a Float) -> GammaIncIncomplete<'a>
Computes the upper incomplete gamma function on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let x = Float::with_val(53, 2.5);
let gamma_inc = Float::with_val(53, f.gamma_inc_ref(&x));
let expected = 0.1116_f64;
assert!((gamma_inc - expected).abs() < 0.0001);
sourcepub fn ln_gamma_ref(&self) -> LnGammaIncomplete<'_>
pub fn ln_gamma_ref(&self) -> LnGammaIncomplete<'_>
Computes the logarithm of the gamma function on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
CompleteRound<Completed = Float> for Src
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let ln_gamma = Float::with_val(53, f.ln_gamma_ref());
let expected = -0.0983_f64;
assert!((ln_gamma - expected).abs() < 0.0001);
sourcepub fn ln_abs_gamma_ref(&self) -> LnAbsGammaIncomplete<'_>
pub fn ln_abs_gamma_ref(&self) -> LnAbsGammaIncomplete<'_>
Computes the logarithm of the absolute value of the gamma function on
val
.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for (Float, Ordering)
Assign<Src> for (&mut Float, &mut Ordering)
AssignRound<Src> for (Float, Ordering)
AssignRound<Src> for (&mut Float, &mut Ordering)
CompleteRound<Completed = (Float, Float)> for Src
§Examples
use core::cmp::Ordering;
use rug::float::Constant;
use rug::{Assign, Float};
let neg1_2 = Float::with_val(53, -0.5);
// gamma of -1/2 is -2√π
let abs_gamma_64 = Float::with_val(64, Constant::Pi).sqrt() * 2u32;
let ln_gamma_64 = abs_gamma_64.ln();
// Assign rounds to the nearest
let r = neg1_2.ln_abs_gamma_ref();
let (mut f, mut sign) = (Float::new(53), Ordering::Equal);
(&mut f, &mut sign).assign(r);
// gamma of -1/2 is negative
assert_eq!(sign, Ordering::Less);
// check to 53 significant bits
assert_eq!(f, Float::with_val(53, &ln_gamma_64));
sourcepub fn digamma_ref(&self) -> DigammaIncomplete<'_>
pub fn digamma_ref(&self) -> DigammaIncomplete<'_>
Computes the Digamma function on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let digamma = Float::with_val(53, f.digamma_ref());
let expected = -0.2275_f64;
assert!((digamma - expected).abs() < 0.0001);
sourcepub fn zeta_ref(&self) -> ZetaIncomplete<'_>
pub fn zeta_ref(&self) -> ZetaIncomplete<'_>
Computes the Riemann Zeta function on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let zeta = Float::with_val(53, f.zeta_ref());
let expected = 4.5951_f64;
assert!((zeta - expected).abs() < 0.0001);
sourcepub fn erf_ref(&self) -> ErfIncomplete<'_>
pub fn erf_ref(&self) -> ErfIncomplete<'_>
Computes the error function.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let erf = Float::with_val(53, f.erf_ref());
let expected = 0.9229_f64;
assert!((erf - expected).abs() < 0.0001);
sourcepub fn erfc_ref(&self) -> ErfcIncomplete<'_>
pub fn erfc_ref(&self) -> ErfcIncomplete<'_>
Computes the complementary error function.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let erfc = Float::with_val(53, f.erfc_ref());
let expected = 0.0771_f64;
assert!((erfc - expected).abs() < 0.0001);
sourcepub fn j0_ref(&self) -> J0Incomplete<'_>
pub fn j0_ref(&self) -> J0Incomplete<'_>
Computes the first kind Bessel function of order 0.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let j0 = Float::with_val(53, f.j0_ref());
let expected = 0.6459_f64;
assert!((j0 - expected).abs() < 0.0001);
sourcepub fn j1_ref(&self) -> J1Incomplete<'_>
pub fn j1_ref(&self) -> J1Incomplete<'_>
Computes the first kind Bessel function of order 1.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let j1 = Float::with_val(53, f.j1_ref());
let expected = 0.5106_f64;
assert!((j1 - expected).abs() < 0.0001);
sourcepub fn jn_ref(&self, n: i32) -> JnIncomplete<'_>
pub fn jn_ref(&self, n: i32) -> JnIncomplete<'_>
Computes the first kind Bessel function of order n.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let j2 = Float::with_val(53, f.jn_ref(2));
let expected = 0.1711_f64;
assert!((j2 - expected).abs() < 0.0001);
sourcepub fn y0_ref(&self) -> Y0Incomplete<'_>
pub fn y0_ref(&self) -> Y0Incomplete<'_>
Computes the second kind Bessel function of order 0.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let y0 = Float::with_val(53, f.y0_ref());
let expected = 0.2582_f64;
assert!((y0 - expected).abs() < 0.0001);
sourcepub fn y1_ref(&self) -> Y1Incomplete<'_>
pub fn y1_ref(&self) -> Y1Incomplete<'_>
Computes the second kind Bessel function of order 1.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let y1 = Float::with_val(53, f.y1_ref());
let expected = -0.5844_f64;
assert!((y1 - expected).abs() < 0.0001);
sourcepub fn yn_ref(&self, n: i32) -> YnIncomplete<'_>
pub fn yn_ref(&self, n: i32) -> YnIncomplete<'_>
Computes the second kind Bessel function of order n.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let y2 = Float::with_val(53, f.yn_ref(2));
let expected = -1.1932_f64;
assert!((y2 - expected).abs() < 0.0001);
sourcepub fn agm_ref<'a>(&'a self, other: &'a Float) -> AgmIncomplete<'a>
pub fn agm_ref<'a>(&'a self, other: &'a Float) -> AgmIncomplete<'a>
Computes the arithmetic-geometric mean.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let g = Float::with_val(53, 3.75);
let agm = Float::with_val(53, f.agm_ref(&g));
let expected = 2.3295_f64;
assert!((agm - expected).abs() < 0.0001);
sourcepub fn hypot_ref<'a>(&'a self, other: &'a Float) -> HypotIncomplete<'a>
pub fn hypot_ref<'a>(&'a self, other: &'a Float) -> HypotIncomplete<'a>
Computes the Euclidean norm.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let g = Float::with_val(53, 3.75);
let hypot = Float::with_val(53, f.hypot_ref(&g));
let expected = 3.9528_f64;
assert!((hypot - expected).abs() < 0.0001);
sourcepub fn ai_ref(&self) -> AiIncomplete<'_>
pub fn ai_ref(&self) -> AiIncomplete<'_>
Computes the Airy function Ai on the value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f = Float::with_val(53, 1.25);
let ai = Float::with_val(53, f.ai_ref());
let expected = 0.0996_f64;
assert!((ai - expected).abs() < 0.0001);
sourcepub fn ceil_ref(&self) -> CeilIncomplete<'_>
pub fn ceil_ref(&self) -> CeilIncomplete<'_>
Rounds up to the next higher integer. The result may be rounded again when assigned to the target.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, -23.75);
let ceil1 = Float::with_val(53, f1.ceil_ref());
assert_eq!(ceil1, -23);
let f2 = Float::with_val(53, 23.75);
let ceil2 = Float::with_val(53, f2.ceil_ref());
assert_eq!(ceil2, 24);
sourcepub fn floor_ref(&self) -> FloorIncomplete<'_>
pub fn floor_ref(&self) -> FloorIncomplete<'_>
Rounds down to the next lower integer. The result may be rounded again when assigned to the target.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, -23.75);
let floor1 = Float::with_val(53, f1.floor_ref());
assert_eq!(floor1, -24);
let f2 = Float::with_val(53, 23.75);
let floor2 = Float::with_val(53, f2.floor_ref());
assert_eq!(floor2, 23);
sourcepub fn round_ref(&self) -> RoundIncomplete<'_>
pub fn round_ref(&self) -> RoundIncomplete<'_>
Rounds to the nearest integer, rounding half-way cases away from zero. The result may be rounded again when assigned to the target.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, -23.75);
let round1 = Float::with_val(53, f1.round_ref());
assert_eq!(round1, -24);
let f2 = Float::with_val(53, 23.75);
let round2 = Float::with_val(53, f2.round_ref());
assert_eq!(round2, 24);
Double rounding may happen when assigning to a target with a precision less than the number of significant bits for the truncated integer.
use rug::float::Round;
use rug::Float;
use rug::ops::AssignRound;
let f = Float::with_val(53, 6.5);
// 6.5 (binary 110.1) is rounded to 7 (binary 111)
let r = f.round_ref();
// use only 2 bits of precision in destination
let mut dst = Float::new(2);
// 7 (binary 111) is rounded to 8 (binary 1000) by
// round-even rule in order to store in 2-bit Float, even
// though 6 (binary 110) is closer to original 6.5).
dst.assign_round(r, Round::Nearest);
assert_eq!(dst, 8);
sourcepub fn round_even_ref(&self) -> RoundEvenIncomplete<'_>
pub fn round_even_ref(&self) -> RoundEvenIncomplete<'_>
Rounds to the nearest integer, rounding half-way cases to even. The result may be rounded again when assigned to the target.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, 23.5);
let round1 = Float::with_val(53, f1.round_even_ref());
assert_eq!(round1, 24);
let f2 = Float::with_val(53, 24.5);
let round2 = Float::with_val(53, f2.round_even_ref());
assert_eq!(round2, 24);
sourcepub fn trunc_ref(&self) -> TruncIncomplete<'_>
pub fn trunc_ref(&self) -> TruncIncomplete<'_>
Rounds to the next integer towards zero. The result may be rounded again when assigned to the target.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, -23.75);
let trunc1 = Float::with_val(53, f1.trunc_ref());
assert_eq!(trunc1, -23);
let f2 = Float::with_val(53, 23.75);
let trunc2 = Float::with_val(53, f2.trunc_ref());
assert_eq!(trunc2, 23);
sourcepub fn fract_ref(&self) -> FractIncomplete<'_>
pub fn fract_ref(&self) -> FractIncomplete<'_>
Gets the fractional part of the number.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
AssignRound<Src> for Float
§Examples
use rug::Float;
let f1 = Float::with_val(53, -23.75);
let fract1 = Float::with_val(53, f1.fract_ref());
assert_eq!(fract1, -0.75);
let f2 = Float::with_val(53, 23.75);
let fract2 = Float::with_val(53, f2.fract_ref());
assert_eq!(fract2, 0.75);
sourcepub fn trunc_fract_ref(&self) -> TruncFractIncomplete<'_>
pub fn trunc_fract_ref(&self) -> TruncFractIncomplete<'_>
Gets the integer and fractional parts of the number.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for (Float, Float)
Assign<Src> for (&mut Float, &mut Float)
AssignRound<Src> for (Float, Float)
AssignRound<Src> for (&mut Float, &mut Float)
§Examples
use rug::{Assign, Float};
let f1 = Float::with_val(53, -23.75);
let r1 = f1.trunc_fract_ref();
let (mut trunc1, mut fract1) = (Float::new(53), Float::new(53));
(&mut trunc1, &mut fract1).assign(r1);
assert_eq!(trunc1, -23);
assert_eq!(fract1, -0.75);
let f2 = Float::with_val(53, -23.75);
let r2 = f2.trunc_fract_ref();
let (mut trunc2, mut fract2) = (Float::new(53), Float::new(53));
(&mut trunc2, &mut fract2).assign(r2);
assert_eq!(trunc2, -23);
assert_eq!(fract2, -0.75);
Trait Implementations§
source§impl AbsDiffEq for FloatWrapper
impl AbsDiffEq for FloatWrapper
source§type Epsilon = FloatWrapper
type Epsilon = FloatWrapper
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
].source§impl Add for FloatWrapper
impl Add for FloatWrapper
source§impl AddAssign for FloatWrapper
impl AddAssign for FloatWrapper
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl Clone for FloatWrapper
impl Clone for FloatWrapper
source§fn clone(&self) -> FloatWrapper
fn clone(&self) -> FloatWrapper
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl ComplexField for FloatWrapper
impl ComplexField for FloatWrapper
type RealField = FloatWrapper
source§fn from_real(re: Self::RealField) -> Self
fn from_real(re: Self::RealField) -> Self
source§fn modulus_squared(self) -> Self::RealField
fn modulus_squared(self) -> Self::RealField
source§fn norm1(self) -> Self::RealField
fn norm1(self) -> Self::RealField
fn floor(self) -> Self
fn ceil(self) -> Self
fn round(self) -> Self
fn trunc(self) -> Self
fn fract(self) -> Self
fn mul_add(self, _a: Self, _b: Self) -> Self
source§fn abs(self) -> Self::RealField
fn abs(self) -> Self::RealField
self / self.signum()
. Read moresource§fn hypot(self, other: Self) -> Self::RealField
fn hypot(self, other: Self) -> Self::RealField
fn recip(self) -> Self
fn conjugate(self) -> Self
fn sin(self) -> Self
fn cos(self) -> Self
fn sin_cos(self) -> (Self, Self)
fn tan(self) -> Self
fn asin(self) -> Self
fn acos(self) -> Self
fn atan(self) -> Self
fn sinh(self) -> Self
fn cosh(self) -> Self
fn tanh(self) -> Self
fn asinh(self) -> Self
fn acosh(self) -> Self
fn atanh(self) -> Self
fn log(self, _base: Self::RealField) -> Self
fn log2(self) -> Self
fn log10(self) -> Self
fn ln(self) -> Self
fn ln_1p(self) -> Self
fn sqrt(self) -> Self
fn exp(self) -> Self
fn exp2(self) -> Self
fn exp_m1(self) -> Self
fn powi(self, _n: i32) -> Self
fn powf(self, _n: Self::RealField) -> Self
fn powc(self, _n: Self) -> Self
fn cbrt(self) -> Self
fn try_sqrt(self) -> Option<Self>
fn is_finite(&self) -> bool
§fn to_polar(self) -> (Self::RealField, Self::RealField)
fn to_polar(self) -> (Self::RealField, Self::RealField)
§fn to_exp(self) -> (Self::RealField, Self)
fn to_exp(self) -> (Self::RealField, Self)
fn sinh_cosh(self) -> (Self, Self)
fn sinhc(self) -> Self
fn coshc(self) -> Self
source§impl Debug for FloatWrapper
impl Debug for FloatWrapper
source§impl Deref for FloatWrapper
impl Deref for FloatWrapper
source§impl Display for FloatWrapper
impl Display for FloatWrapper
source§impl Div for FloatWrapper
impl Div for FloatWrapper
source§impl DivAssign for FloatWrapper
impl DivAssign for FloatWrapper
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moresource§impl From<Float> for FloatWrapper
impl From<Float> for FloatWrapper
source§impl FromPrimitive for FloatWrapper
impl FromPrimitive for FloatWrapper
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_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_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_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_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_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§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_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§impl Mul for FloatWrapper
impl Mul for FloatWrapper
source§impl MulAssign for FloatWrapper
impl MulAssign for FloatWrapper
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moresource§impl Neg for FloatWrapper
impl Neg for FloatWrapper
source§impl Num for FloatWrapper
impl Num for FloatWrapper
type FromStrRadixErr = ParseFloatError
source§fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl One for FloatWrapper
impl One for FloatWrapper
source§impl PartialEq for FloatWrapper
impl PartialEq for FloatWrapper
source§impl PartialOrd for FloatWrapper
impl PartialOrd for FloatWrapper
source§impl RealField for FloatWrapper
impl RealField for FloatWrapper
source§fn is_sign_positive(&self) -> bool
fn is_sign_positive(&self) -> bool
source§fn is_sign_negative(&self) -> bool
fn is_sign_negative(&self) -> bool
fn max(self, _other: Self) -> Self
fn min(self, _other: Self) -> Self
fn clamp(self, _min: Self, _max: Self) -> Self
fn atan2(self, _other: Self) -> Self
source§fn min_value() -> Option<Self>
fn min_value() -> Option<Self>
source§fn max_value() -> Option<Self>
fn max_value() -> Option<Self>
fn pi() -> Self
fn two_pi() -> Self
fn frac_pi_2() -> Self
fn frac_pi_3() -> Self
fn frac_pi_4() -> Self
fn frac_pi_6() -> Self
fn frac_pi_8() -> Self
fn frac_1_pi() -> Self
fn frac_2_pi() -> Self
fn frac_2_sqrt_pi() -> Self
fn e() -> Self
fn log2_e() -> Self
fn log10_e() -> Self
fn ln_2() -> Self
fn ln_10() -> Self
source§impl RelativeEq for FloatWrapper
impl RelativeEq for FloatWrapper
source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
].source§impl Rem for FloatWrapper
impl Rem for FloatWrapper
source§impl RemAssign for FloatWrapper
impl RemAssign for FloatWrapper
source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%=
operation. Read moresource§impl Signed for FloatWrapper
impl Signed for FloatWrapper
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
source§impl SimdValue for FloatWrapper
impl SimdValue for FloatWrapper
source§type Element = FloatWrapper
type Element = FloatWrapper
source§unsafe fn extract_unchecked(&self, _: usize) -> Self::Element
unsafe fn extract_unchecked(&self, _: usize) -> Self::Element
self
without bound-checking. Read moresource§unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)
unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)
§fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Selfwhere
Self: Clone,
fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Selfwhere
Self: Clone,
self
. Read more§fn zip_map_lanes(
self,
b: Self,
f: impl Fn(Self::Element, Self::Element) -> Self::Element,
) -> Selfwhere
Self: Clone,
fn zip_map_lanes(
self,
b: Self,
f: impl Fn(Self::Element, Self::Element) -> Self::Element,
) -> Selfwhere
Self: Clone,
source§impl Sub for FloatWrapper
impl Sub for FloatWrapper
source§impl SubAssign for FloatWrapper
impl SubAssign for FloatWrapper
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moresource§impl SubsetOf<FloatWrapper> for FloatWrapper
impl SubsetOf<FloatWrapper> for FloatWrapper
source§fn to_superset(&self) -> Self
fn to_superset(&self) -> Self
self
to the equivalent element of its superset.source§fn from_superset_unchecked(element: &Self) -> Self
fn from_superset_unchecked(element: &Self) -> Self
self.to_superset
but without any property checks. Always succeeds.source§fn is_in_subset(_element: &Self) -> bool
fn is_in_subset(_element: &Self) -> bool
element
is actually part of the subset Self
(and can be converted to it).§fn from_superset(element: &T) -> Option<Self>
fn from_superset(element: &T) -> Option<Self>
self
from the equivalent element of its
superset. Read moresource§impl SupersetOf<f32> for FloatWrapper
impl SupersetOf<f32> for FloatWrapper
source§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset(&self) -> Option<f32>
fn to_subset(&self) -> Option<f32>
self
from the equivalent element of its
superset. Read moresource§fn to_subset_unchecked(&self) -> f32
fn to_subset_unchecked(&self) -> f32
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &f32) -> Self
fn from_subset(element: &f32) -> Self
self
to the equivalent element of its superset.source§impl SupersetOf<f64> for FloatWrapper
impl SupersetOf<f64> for FloatWrapper
source§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset(&self) -> Option<f64>
fn to_subset(&self) -> Option<f64>
self
from the equivalent element of its
superset. Read moresource§fn to_subset_unchecked(&self) -> f64
fn to_subset_unchecked(&self) -> f64
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &f64) -> Self
fn from_subset(element: &f64) -> Self
self
to the equivalent element of its superset.source§impl UlpsEq for FloatWrapper
impl UlpsEq for FloatWrapper
source§impl Zero for FloatWrapper
impl Zero for FloatWrapper
impl Field for FloatWrapper
impl StructuralPartialEq for FloatWrapper
Auto Trait Implementations§
impl Freeze for FloatWrapper
impl RefUnwindSafe for FloatWrapper
impl Send for FloatWrapper
impl Sync for FloatWrapper
impl Unpin for FloatWrapper
impl UnwindSafe for FloatWrapper
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
source§impl<T> PercentileResolve for T
impl<T> PercentileResolve for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> SimdComplexField for Twhere
T: ComplexField,
impl<T> SimdComplexField for Twhere
T: ComplexField,
§type SimdRealField = <T as ComplexField>::RealField
type SimdRealField = <T as ComplexField>::RealField
§fn from_simd_real(re: <T as SimdComplexField>::SimdRealField) -> T
fn from_simd_real(re: <T as SimdComplexField>::SimdRealField) -> T
§fn simd_imaginary(self) -> <T as SimdComplexField>::SimdRealField
fn simd_imaginary(self) -> <T as SimdComplexField>::SimdRealField
§fn simd_modulus(self) -> <T as SimdComplexField>::SimdRealField
fn simd_modulus(self) -> <T as SimdComplexField>::SimdRealField
§fn simd_modulus_squared(self) -> <T as SimdComplexField>::SimdRealField
fn simd_modulus_squared(self) -> <T as SimdComplexField>::SimdRealField
§fn simd_argument(self) -> <T as SimdComplexField>::SimdRealField
fn simd_argument(self) -> <T as SimdComplexField>::SimdRealField
§fn simd_norm1(self) -> <T as SimdComplexField>::SimdRealField
fn simd_norm1(self) -> <T as SimdComplexField>::SimdRealField
§fn simd_scale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
fn simd_scale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
factor
.§fn simd_unscale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
fn simd_unscale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
factor
.§fn simd_to_polar(
self,
) -> (<T as SimdComplexField>::SimdRealField, <T as SimdComplexField>::SimdRealField)
fn simd_to_polar( self, ) -> (<T as SimdComplexField>::SimdRealField, <T as SimdComplexField>::SimdRealField)
§fn simd_to_exp(self) -> (<T as SimdComplexField>::SimdRealField, T)
fn simd_to_exp(self) -> (<T as SimdComplexField>::SimdRealField, T)
§fn simd_signum(self) -> T
fn simd_signum(self) -> T
self / self.modulus()
fn simd_floor(self) -> T
fn simd_ceil(self) -> T
fn simd_round(self) -> T
fn simd_trunc(self) -> T
fn simd_fract(self) -> T
fn simd_mul_add(self, a: T, b: T) -> T
§fn simd_abs(self) -> <T as SimdComplexField>::SimdRealField
fn simd_abs(self) -> <T as SimdComplexField>::SimdRealField
self / self.signum()
. Read more§fn simd_hypot(self, other: T) -> <T as SimdComplexField>::SimdRealField
fn simd_hypot(self, other: T) -> <T as SimdComplexField>::SimdRealField
fn simd_recip(self) -> T
fn simd_conjugate(self) -> T
fn simd_sin(self) -> T
fn simd_cos(self) -> T
fn simd_sin_cos(self) -> (T, T)
fn simd_sinh_cosh(self) -> (T, T)
fn simd_tan(self) -> T
fn simd_asin(self) -> T
fn simd_acos(self) -> T
fn simd_atan(self) -> T
fn simd_sinh(self) -> T
fn simd_cosh(self) -> T
fn simd_tanh(self) -> T
fn simd_asinh(self) -> T
fn simd_acosh(self) -> T
fn simd_atanh(self) -> T
fn simd_sinhc(self) -> T
fn simd_coshc(self) -> T
fn simd_log(self, base: <T as SimdComplexField>::SimdRealField) -> T
fn simd_log2(self) -> T
fn simd_log10(self) -> T
fn simd_ln(self) -> T
fn simd_ln_1p(self) -> T
fn simd_sqrt(self) -> T
fn simd_exp(self) -> T
fn simd_exp2(self) -> T
fn simd_exp_m1(self) -> T
fn simd_powi(self, n: i32) -> T
fn simd_powf(self, n: <T as SimdComplexField>::SimdRealField) -> T
fn simd_powc(self, n: T) -> T
fn simd_cbrt(self) -> T
§fn simd_horizontal_sum(self) -> <T as SimdValue>::Element
fn simd_horizontal_sum(self) -> <T as SimdValue>::Element
self
.§fn simd_horizontal_product(self) -> <T as SimdValue>::Element
fn simd_horizontal_product(self) -> <T as SimdValue>::Element
self
.§impl<T> SimdPartialOrd for Twhere
T: SimdValue<Element = T, SimdBool = bool> + PartialOrd,
impl<T> SimdPartialOrd for Twhere
T: SimdValue<Element = T, SimdBool = bool> + PartialOrd,
§fn simd_clamp(self, min: T, max: T) -> T
fn simd_clamp(self, min: T, max: T) -> T
self
between the corresponding lane of min
and max
.§fn simd_horizontal_min(self) -> <T as SimdValue>::Element
fn simd_horizontal_min(self) -> <T as SimdValue>::Element
self
.§fn simd_horizontal_max(self) -> <T as SimdValue>::Element
fn simd_horizontal_max(self) -> <T as SimdValue>::Element
self
.§impl<T> SimdRealField for Twhere
T: RealField,
impl<T> SimdRealField for Twhere
T: RealField,
fn simd_atan2(self, other: T) -> T
fn simd_default_epsilon() -> T
§fn simd_copysign(self, sign: T) -> T
fn simd_copysign(self, sign: T) -> T
fn simd_pi() -> T
fn simd_two_pi() -> T
fn simd_frac_pi_2() -> T
fn simd_frac_pi_3() -> T
fn simd_frac_pi_4() -> T
fn simd_frac_pi_6() -> T
fn simd_frac_pi_8() -> T
fn simd_frac_1_pi() -> T
fn simd_frac_2_pi() -> T
fn simd_frac_2_sqrt_pi() -> T
fn simd_e() -> T
fn simd_log2_e() -> T
fn simd_log10_e() -> T
fn simd_ln_2() -> T
fn simd_ln_10() -> T
§impl<T> SimdSigned for T
impl<T> SimdSigned for T
§fn simd_abs_sub(&self, other: &T) -> T
fn simd_abs_sub(&self, other: &T) -> T
self
. Read more§fn simd_signum(&self) -> T
fn simd_signum(&self) -> T
Self
.§fn is_simd_positive(&self) -> <T as SimdValue>::SimdBool
fn is_simd_positive(&self) -> <T as SimdValue>::SimdBool
§fn is_simd_negative(&self) -> <T as SimdValue>::SimdBool
fn is_simd_negative(&self) -> <T as SimdValue>::SimdBool
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.