Skip to main content

MpFloat

Struct MpFloat 

Source
pub struct MpFloat { /* private fields */ }
Expand description

Arbitrary-precision floating-point number.

Wraps DBig with a precision (in binary bits) stored alongside so that prec() returns the correct bit width. All arithmetic is carried out at the stored precision.

Implementations§

Source§

impl MpFloat

Source

pub fn with_val(bits: u32, v: f64) -> Self

Create a new MpFloat from an f64 at the given bit precision.

§Examples
use oxinum_float::mp_float::MpFloat;
let x = MpFloat::with_val(256, 3.14f64);
assert!((x.to_f64() - 3.14).abs() < 1e-10);
Source

pub fn with_val_from(bits: u32, other: &MpFloat) -> Self

Create a new MpFloat from another MpFloat value at the given bit precision (analogous to rug::Float::with_val(bits, &other)).

Source

pub fn from_dbig(d: &DBig, bits: u32) -> Self

Create from a DBig reference, using the existing precision.

Source

pub fn prec(&self) -> u32

Return the precision in binary bits.

Source

pub fn decimal_prec(&self) -> usize

Return the decimal precision used internally.

Source

pub fn to_f64(&self) -> f64

Convert to f64 (may lose precision).

Source

pub fn as_dbig(&self) -> &DBig

Borrow the inner DBig.

Source

pub fn is_zero(&self) -> bool

True if the value is exactly zero.

Source

pub fn is_finite(&self) -> bool

True if the value is finite (always true for DBig).

Source

pub fn is_integer(&self) -> bool

True if the value is an integer (fractional part is zero).

Source

pub fn is_sign_positive(&self) -> bool

True if the value is strictly positive.

Source

pub fn is_sign_negative(&self) -> bool

True if the value is strictly negative.

Source

pub fn abs(self) -> Self

Absolute value.

Source

pub fn sqrt(self) -> Self

Square root. Returns 0 for negative inputs (mirrors MPFR NaN→0 fallback).

Source

pub fn exp(self) -> Self

Exponential e^x.

Source

pub fn ln(self) -> Self

Natural logarithm. Returns 0 for x ≤ 0 (fallback).

Source

pub fn sin(self) -> Self

Sine.

Source

pub fn cos(self) -> Self

Cosine.

Source

pub fn gamma(self) -> Self

Gamma function Γ(self).

Source

pub fn gamma_mut(&mut self)

Apply gamma function in-place (mirrors rug::Float::gamma_mut()).

Source

pub fn ln_gamma(self) -> Self

Log-gamma function ln(Γ(self)).

Source

pub fn ln_gamma_mut(&mut self)

Apply log-gamma in-place (mirrors rug::Float::ln_gamma_mut()).

Source

pub fn digamma(self) -> Self

Digamma function ψ(self).

Source

pub fn digamma_mut(&mut self)

Apply digamma in-place (mirrors rug::Float::digamma_mut()).

Source

pub fn erf(self) -> Self

Error function erf(self).

Source

pub fn erf_mut(&mut self)

Apply erf in-place (mirrors rug::Float::erf_mut()).

Source

pub fn erfc(self) -> Self

Complementary error function erfc(self).

Source

pub fn erfc_mut(&mut self)

Apply erfc in-place (mirrors rug::Float::erfc_mut()).

Source

pub fn j0(self) -> Self

Bessel function J₀(self).

Source

pub fn j0_mut(&mut self)

Apply j0 in-place (mirrors rug::Float::j0_mut()).

Source

pub fn pow_float(self, exp: &MpFloat) -> Self

Raise to the power of another MpFloat.

Source

pub fn pow_i32(self, exp: i32) -> Self

Raise to an integer power.

Source

pub fn pow_f64(self, exp: f64) -> Self

Raise to an f64 power (convenience).

Trait Implementations§

Source§

impl Add for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: MpFloat) -> MpFloat

Performs the + operation. Read more
Source§

impl Add<&MpFloat> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &MpFloat) -> MpFloat

Performs the + operation. Read more
Source§

impl Add<&MpFloat> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &MpFloat) -> MpFloat

Performs the + operation. Read more
Source§

impl Add<f64> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> MpFloat

Performs the + operation. Read more
Source§

impl Add<f64> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> MpFloat

Performs the + operation. Read more
Source§

impl AddAssign for MpFloat

Source§

fn add_assign(&mut self, rhs: MpFloat)

Performs the += operation. Read more
Source§

impl AddAssign<&MpFloat> for MpFloat

Source§

fn add_assign(&mut self, rhs: &MpFloat)

Performs the += operation. Read more
Source§

impl AddAssign<f64> for MpFloat

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl Clone for MpFloat

Source§

fn clone(&self) -> MpFloat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MpFloat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MpFloat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: MpFloat) -> MpFloat

Performs the / operation. Read more
Source§

impl Div<&MpFloat> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &MpFloat) -> MpFloat

Performs the / operation. Read more
Source§

impl Div<&MpFloat> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &MpFloat) -> MpFloat

Performs the / operation. Read more
Source§

impl Div<f64> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> MpFloat

Performs the / operation. Read more
Source§

impl Div<f64> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> MpFloat

Performs the / operation. Read more
Source§

impl DivAssign for MpFloat

Source§

fn div_assign(&mut self, rhs: MpFloat)

Performs the /= operation. Read more
Source§

impl DivAssign<&MpFloat> for MpFloat

Source§

fn div_assign(&mut self, rhs: &MpFloat)

Performs the /= operation. Read more
Source§

impl DivAssign<f64> for MpFloat

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl LowerExp for MpFloat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MpPow<&MpFloat> for MpFloat

Source§

fn pow(self, exp: &MpFloat) -> MpFloat

Source§

impl MpPow<MpFloat> for MpFloat

Source§

fn pow(self, exp: MpFloat) -> MpFloat

Source§

impl MpPow<f64> for MpFloat

Source§

fn pow(self, exp: f64) -> MpFloat

Source§

impl MpPow<i32> for MpFloat

Source§

fn pow(self, exp: i32) -> MpFloat

Source§

impl Mul for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: MpFloat) -> MpFloat

Performs the * operation. Read more
Source§

impl Mul<&MpFloat> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &MpFloat) -> MpFloat

Performs the * operation. Read more
Source§

impl Mul<&MpFloat> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &MpFloat) -> MpFloat

Performs the * operation. Read more
Source§

impl Mul<f64> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> MpFloat

Performs the * operation. Read more
Source§

impl Mul<f64> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> MpFloat

Performs the * operation. Read more
Source§

impl MulAssign for MpFloat

Source§

fn mul_assign(&mut self, rhs: MpFloat)

Performs the *= operation. Read more
Source§

impl MulAssign<&MpFloat> for MpFloat

Source§

fn mul_assign(&mut self, rhs: &MpFloat)

Performs the *= operation. Read more
Source§

impl MulAssign<f64> for MpFloat

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl Neg for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn neg(self) -> MpFloat

Performs the unary - operation. Read more
Source§

impl Neg for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn neg(self) -> MpFloat

Performs the unary - operation. Read more
Source§

impl PartialEq for MpFloat

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for MpFloat

Source§

fn eq(&self, other: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for MpFloat

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for MpFloat

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: MpFloat) -> MpFloat

Performs the - operation. Read more
Source§

impl Sub<&MpFloat> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &MpFloat) -> MpFloat

Performs the - operation. Read more
Source§

impl Sub<&MpFloat> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &MpFloat) -> MpFloat

Performs the - operation. Read more
Source§

impl Sub<f64> for &MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> MpFloat

Performs the - operation. Read more
Source§

impl Sub<f64> for MpFloat

Source§

type Output = MpFloat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> MpFloat

Performs the - operation. Read more
Source§

impl SubAssign for MpFloat

Source§

fn sub_assign(&mut self, rhs: MpFloat)

Performs the -= operation. Read more
Source§

impl SubAssign<&MpFloat> for MpFloat

Source§

fn sub_assign(&mut self, rhs: &MpFloat)

Performs the -= operation. Read more
Source§

impl SubAssign<f64> for MpFloat

Source§

fn sub_assign(&mut self, rhs: f64)

Performs the -= operation. Read more
Source§

impl UpperExp for MpFloat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.