Skip to main content

BigFloat

Struct BigFloat 

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

Native arbitrary-precision binary float.

BigFloat represents (-1)^sign * mantissa * 2^exponent with precision significant bits. See the module-level documentation for the full invariant list.

§Examples

use oxinum_float::native::{BigFloat, RoundingMode};

let a = BigFloat::from_i64(3, 8, RoundingMode::HalfEven);
let b = BigFloat::from_i64(5, 8, RoundingMode::HalfEven);
let sum = &a + &b;
assert_eq!(sum.to_f64(), 8.0);

Implementations§

Source§

impl BigFloat

Source

pub fn atan(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return atan(self) at prec bits using the given rounding mode.

The result lies in (−π/2, π/2).

§Errors

Propagates sqrt or division errors (only if internal invariants break, which should not happen for well-formed inputs).

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let one = BigFloat::from_i64(1, 64, RoundingMode::HalfEven);
let a = one.atan(64, RoundingMode::HalfEven).expect("atan(1)");
// atan(1) = π/4 ≈ 0.7853981633974483
assert!((a.to_f64() - std::f64::consts::FRAC_PI_4).abs() < 1e-14);
Source

pub fn atan2( &self, x: &BigFloat, prec: u32, mode: RoundingMode, ) -> OxiNumResult<BigFloat>

Return atan2(self, x) at prec bits using the given rounding mode.

Conventionally atan2(y, x)self is y and x is the argument. The result lies in (−π, π].

§Special cases
  • atan2(0, 0) = 0 (by convention, not mathematically defined).
  • atan2(y, 0) = ±π/2 depending on sign of y.
§Errors

Propagates errors from BigFloat::atan.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let y = BigFloat::from_i64(1, 64, RoundingMode::HalfEven);
let x = BigFloat::from_i64(1, 64, RoundingMode::HalfEven);
let a = y.atan2(&x, 64, RoundingMode::HalfEven).expect("atan2(1,1)");
// atan2(1,1) = π/4 ≈ 0.7853981633974483
assert!((a.to_f64() - std::f64::consts::FRAC_PI_4).abs() < 1e-14);
Source§

impl BigFloat

Source

pub fn zero(prec: u32) -> Self

Canonical zero at prec bits of precision.

§Panics

Panics if prec == 0 (the precision invariant requires prec > 0).

§Examples
use oxinum_float::native::BigFloat;
let z = BigFloat::zero(53);
assert!(z.is_zero());
assert_eq!(z.precision(), 53);
Source

pub fn nan(prec: u32) -> Self

Create a canonical NaN at prec bits. NaN’s sign is always Positive.

Source

pub fn infinity(prec: u32) -> Self

Create positive infinity (+∞) at prec bits.

Source

pub fn neg_infinity(prec: u32) -> Self

Create negative infinity (−∞) at prec bits.

Source

pub fn from_parts( sign: Sign, mantissa: BigUint, exponent: i64, prec: u32, mode: RoundingMode, ) -> Self

Construct directly from already-validated parts.

The result is normalized (trailing-zero bits migrated into the exponent) and then rounded to prec bits if the normalized mantissa is wider than prec. If the normalized mantissa is narrower, it is left-padded so mantissa.bit_length() == prec while preserving the mathematical value.

Used by every higher-level constructor (from_i64, from_f64, arithmetic) — call this whenever you need to land back at the canonical invariant from arbitrary parts.

Source

pub fn precision(&self) -> u32

Returns the precision in bits.

Source

pub fn sign(&self) -> Sign

Returns the sign.

For the canonical zero, the sign is always Sign::Positive.

Source

pub fn mantissa(&self) -> &BigUint

Returns a reference to the mantissa.

Source

pub fn exponent(&self) -> i64

Returns the binary exponent (the power of 2 the mantissa is scaled by).

Source

pub fn is_zero(&self) -> bool

Returns true if this value is the canonical zero.

NaN and Inf have mantissa = 0 internally, so this check requires testing the class field first.

Source

pub fn is_finite(&self) -> bool

Returns true if this value is finite (not NaN or Inf).

Source

pub fn is_infinite(&self) -> bool

Returns true if this value is infinite (+∞ or −∞).

Source

pub fn is_nan(&self) -> bool

Returns true if this value is NaN.

Source

pub fn is_normal(&self) -> bool

Returns true for finite non-zero values.

Arbitrary-precision floats have no Subnormal category — every nonzero finite value is Normal.

Source

pub fn classify(&self) -> FpCategory

Returns the IEEE 754 float class.

FpCategory::Subnormal is never returned: there is no fixed exponent range in arbitrary-precision arithmetic, so every nonzero finite value is Normal.

Source

pub fn is_sign_positive(&self) -> bool

Returns true for positive and NaN values (NaN has canonical positive sign).

Note: unlike f64, the single canonical zero has is_sign_positive() == true.

Source

pub fn is_sign_negative(&self) -> bool

Returns true only for negative-sign values (negative Inf or negative finite).

Note: canonical zero has is_sign_negative() == false (no signed zero).

Source

pub fn signum(&self) -> i32

Returns -1, 0, or +1 depending on the sign of the value.

Source

pub fn abs(&self) -> Self

Returns the absolute value (sign forced to Sign::Positive).

Source

pub fn neg(&self) -> Self

Returns the additive inverse.

Negating the canonical zero yields the canonical zero (sign stays Positive). Negating NaN returns NaN unchanged (the canonical NaN always has sign Positive).

Source

pub fn with_precision(self, prec: u32, mode: RoundingMode) -> Self

Change the precision, rounding the mantissa with mode if narrowing.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let a = BigFloat::from_i64(7, 8, RoundingMode::HalfEven);
let b = a.with_precision(64, RoundingMode::HalfEven);
assert_eq!(b.precision(), 64);
assert_eq!(b.to_f64(), 7.0);
Source

pub fn round_to_precision(self, prec: u32, mode: RoundingMode) -> Self

Round the mantissa so that, after normalization, it has exactly prec significant bits.

If the current mantissa has fewer bits than prec, the result is left-padded; the mathematical value is unchanged. If it has more bits, the low bits are discarded according to mode.

Source§

impl BigFloat

Source

pub fn total_cmp(&self, other: &Self) -> Ordering

IEEE 754-style total order, suitable for sorting.

Sequence: −Inf < (negative finite) < zero < (positive finite) < +Inf < NaN.

Because this type has a single canonical zero and a single canonical NaN, total_cmp(NaN, NaN) == Equal and total_cmp(+Inf, NaN) == Less.

Source§

impl BigFloat

Source

pub fn add_ref(&self, other: &BigFloat) -> BigFloat

Return self + other, rounding the result to max(self.precision, other.precision) using banker’s rounding.

Source

pub fn add_ref_with_mode( &self, other: &BigFloat, mode: RoundingMode, ) -> BigFloat

Return self + other, rounding the result to max(self.precision, other.precision) using the chosen rounding mode.

Source

pub fn sub_ref(&self, other: &BigFloat) -> BigFloat

Return self - other at max(p_self, p_other) precision, banker’s rounding.

Source

pub fn sub_ref_with_mode( &self, other: &BigFloat, mode: RoundingMode, ) -> BigFloat

Return self - other at max(p_self, p_other) precision with the given rounding mode.

Source§

impl BigFloat

Source

pub fn to_bigint_trunc(&self) -> BigInt

Convert to BigInt by truncating toward zero (round-toward-zero).

Returns the integer part of self, discarding any fractional bits.

Non-finite values (NaN, ±Inf) have no integer representation. This method returns BigInt::zero() as a documented lossy fallback for those inputs; callers that may encounter non-finite values should use BigFloat::is_finite to guard before calling.

§Examples
use oxinum_float::native::BigFloat;
use oxinum_int::native::BigInt;

let x = BigFloat::from_f64(3.7, 64).expect("3.7");
assert_eq!(x.to_bigint_trunc(), BigInt::from(3i64));

let y = BigFloat::from_f64(-3.7, 64).expect("-3.7");
assert_eq!(y.to_bigint_trunc(), BigInt::from(-3i64));

// Non-finite values return zero (lossy).
assert_eq!(BigFloat::nan(53).to_bigint_trunc(), BigInt::zero());
assert_eq!(BigFloat::infinity(53).to_bigint_trunc(), BigInt::zero());
Source

pub fn to_bigint_floor(&self) -> BigInt

Convert to BigInt by rounding toward negative infinity (floor).

For negative values with a non-zero fractional part, the result is one less than the truncation (i.e. more negative).

§Examples
use oxinum_float::native::BigFloat;
use oxinum_int::native::BigInt;

let x = BigFloat::from_f64(3.7, 64).expect("3.7");
assert_eq!(x.to_bigint_floor(), BigInt::from(3i64));

let y = BigFloat::from_f64(-3.7, 64).expect("-3.7");
assert_eq!(y.to_bigint_floor(), BigInt::from(-4i64));
Source

pub fn to_bigint_ceil(&self) -> BigInt

Convert to BigInt by rounding toward positive infinity (ceiling).

For positive values with a non-zero fractional part, the result is one more than the truncation.

§Examples
use oxinum_float::native::BigFloat;
use oxinum_int::native::BigInt;

let x = BigFloat::from_f64(3.7, 64).expect("3.7");
assert_eq!(x.to_bigint_ceil(), BigInt::from(4i64));

let y = BigFloat::from_f64(-3.7, 64).expect("-3.7");
assert_eq!(y.to_bigint_ceil(), BigInt::from(-3i64));
Source

pub fn to_bigint_round(&self) -> BigInt

Convert to BigInt by rounding half-away-from-zero.

  • Fractional part < 1/2: truncate toward zero.
  • Fractional part == 1/2: round away from zero (ties-away).
  • Fractional part > 1/2: round away from zero.
§Examples
use oxinum_float::native::BigFloat;
use oxinum_int::native::BigInt;

let x = BigFloat::from_f64(3.7, 64).expect("3.7");
assert_eq!(x.to_bigint_round(), BigInt::from(4i64));

let y = BigFloat::from_f64(-3.7, 64).expect("-3.7");
assert_eq!(y.to_bigint_round(), BigInt::from(-4i64));
Source§

impl BigFloat

Source

pub fn from_i64(n: i64, prec: u32, mode: RoundingMode) -> Self

Encode the integer n as a BigFloat at prec bits of precision.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let a = BigFloat::from_i64(-42, 16, RoundingMode::HalfEven);
assert_eq!(a.to_f64(), -42.0);
Source

pub fn from_f64(x: f64, prec: u32) -> OxiNumResult<Self>

Decompose an IEEE-754 f64 value into a BigFloat at prec bits.

At prec >= 53 the decomposition is exact (no rounding occurs). The rounding mode used for any narrowing is RoundingMode::HalfEven.

§Errors

Returns OxiNumError::Parse if x is NaN or infinite — native BigFloat does not yet model those special values.

§Examples
use oxinum_float::native::BigFloat;
let half = BigFloat::from_f64(0.5, 1).expect("0.5 fits in 1 bit");
assert_eq!(half.to_f64(), 0.5);
Source

pub fn to_f64(&self) -> f64

Round to the nearest f64 (ties-to-even). Values whose magnitudes exceed f64::MAX saturate to ±∞, and underflows round to ±0.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let one = BigFloat::from_i64(1, 53, RoundingMode::HalfEven);
assert_eq!(one.to_f64(), 1.0);
Source§

impl BigFloat

Source

pub fn from_bigint(n: &BigInt, prec: u32, mode: RoundingMode) -> Self

Convert a BigInt (signed arbitrary-precision integer) to BigFloat at prec bits of precision using the given rounding mode.

The conversion is exact when prec >= n.magnitude().bit_length(); otherwise the result is rounded according to mode.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
use oxinum_int::native::BigInt;

let n = BigInt::from(-42i64);
let f = BigFloat::from_bigint(&n, 64, RoundingMode::HalfEven);
assert_eq!(f.to_f64(), -42.0);
Source

pub fn from_biguint(n: &BigUint, prec: u32, mode: RoundingMode) -> Self

Convert a BigUint (non-negative arbitrary-precision integer) to BigFloat at prec bits of precision using the given rounding mode.

The conversion is exact when prec >= n.bit_length(); otherwise the result is rounded according to mode.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
use oxinum_int::native::BigUint;

let n = BigUint::from_u64(1024);
let f = BigFloat::from_biguint(&n, 64, RoundingMode::HalfEven);
assert_eq!(f.to_f64(), 1024.0);
Source§

impl BigFloat

Source

pub fn div_ref(&self, other: &BigFloat) -> OxiNumResult<BigFloat>

Return self / other at max(p_self, p_other) precision using banker’s rounding.

§Errors

Returns OxiNumError::DivByZero if other is the canonical zero.

Source

pub fn div_ref_with_mode( &self, other: &BigFloat, mode: RoundingMode, ) -> OxiNumResult<BigFloat>

Return self / other at max(p_self, p_other) precision with the given rounding mode.

§Errors

Returns OxiNumError::DivByZero if other is the canonical zero.

Source§

impl BigFloat

Source

pub fn exp(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return e^self at prec bits using the chosen rounding mode.

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode, e_const};
let one = BigFloat::from_i64(1, 100, RoundingMode::HalfEven);
let result = one.exp(100, RoundingMode::HalfEven).expect("exp(1)");
let e = e_const(100).expect("e_const");
let diff = (result.to_f64() - e.to_f64()).abs();
assert!(diff < 1e-14);
Source§

impl BigFloat

Source

pub fn ln(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return ln(self) at prec bits using the chosen rounding mode.

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let one = BigFloat::from_i64(1, 64, RoundingMode::HalfEven);
let result = one.ln(64, RoundingMode::HalfEven).expect("ln(1)");
assert!(result.is_zero());
Source§

impl BigFloat

Source

pub fn mul_ref(&self, other: &BigFloat) -> BigFloat

Return self * other, rounding the result to max(self.precision, other.precision) using banker’s rounding.

Source

pub fn mul_ref_with_mode( &self, other: &BigFloat, mode: RoundingMode, ) -> BigFloat

Return self * other, rounding the result to max(self.precision, other.precision) using the chosen rounding mode.

Source§

impl BigFloat

Source

pub fn sqrt(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<Self>

Return sqrt(self) at prec bits using the chosen rounding mode.

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let four = BigFloat::from_i64(4, 32, RoundingMode::HalfEven);
let two = four.sqrt(32, RoundingMode::HalfEven).expect("sqrt(4) is real");
assert_eq!(two.to_f64(), 2.0);
Source§

impl BigFloat

Source

pub fn to_scientific_string(&self, sig_digits: usize) -> String

Render this value in decimal scientific notation with sig_digits significant digits: d.ddd…e±E (a single digit before the point).

The value is rounded (ties to even) to sig_digits significant decimal digits. sig_digits is clamped to at least 1.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let x = BigFloat::from_i64(12345, 64, RoundingMode::HalfEven);
assert_eq!(x.to_scientific_string(5), "1.2345e4");
assert_eq!(x.to_scientific_string(1), "1e4");
Source

pub fn to_engineering_string(&self, sig_digits: usize) -> String

Render this value in decimal engineering notation with sig_digits significant digits.

Engineering notation is scientific notation constrained so the decimal exponent is always a multiple of three and the displayed mantissa lies in [1, 1000). The mantissa therefore carries one, two, or three digits before the point.

The value is rounded (ties to even) to sig_digits significant decimal digits. sig_digits is clamped to at least 1.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let x = BigFloat::from_i64(12345, 64, RoundingMode::HalfEven);
assert_eq!(x.to_engineering_string(5), "12.345e3");
Source§

impl BigFloat

Source

pub fn to_hex_string(&self) -> String

Render this value as a C99 %a-style hexadecimal float string: ±0x1.<hex-frac>p±<binexp>.

The rendering is binary-exact: the leading mantissa bit becomes the 1 before the point, the remaining bits are grouped (MSB-first) into 4-bit hex nibbles after the point, and the p exponent is the binary exponent of the leading bit. The canonical zero renders as 0x0p0.

BigFloat::from_hex_float is the exact inverse, so from_hex_float(x.to_hex_string()) reproduces x bit-for-bit.

§Examples
use oxinum_float::native::BigFloat;
let x = BigFloat::from_f64(12.0, 53).expect("finite");
// 12 = 1.1000…b × 2^3  →  0x1.8p3
assert_eq!(x.to_hex_string(), "0x1.8p3");
Source

pub fn from_hex_float(s: &str, prec: u32) -> OxiNumResult<Self>

Parse a C99 %a-style hexadecimal float string into a BigFloat at prec bits of precision.

Accepts ±0x<hexint>[.<hexfrac>]p±<decexp> (the 0x/0X prefix, at least one hex digit overall, and the p/P binary exponent are all mandatory). The parse is binary-exact before the final normalization/rounding to prec bits.

§Errors

Returns OxiNumError::Parse on any malformed input: a missing 0x prefix, a missing p exponent, non-hex digits in the significand, a non-decimal exponent, or stray characters.

§Examples
use oxinum_float::native::BigFloat;
// 0x1.8p3 = 1.5 × 2^3 = 12.
let x = BigFloat::from_hex_float("0x1.8p3", 53).expect("valid hex float");
assert_eq!(x.to_f64(), 12.0);
Source§

impl BigFloat

Source

pub fn ln_agm(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return ln(self) at prec bits using the AGM algorithm.

This is algorithmically distinct from BigFloat::ln, which uses Newton-Raphson iteration on the exponential. The AGM method converges quadratically from the start (no f64 seed required) and avoids calling exp internally, making it independent of the Taylor-series path.

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let two = BigFloat::from_i64(2, 64, RoundingMode::HalfEven);
let result = two.ln_agm(64, RoundingMode::HalfEven).expect("ln_agm(2)");
assert!((result.to_f64() - std::f64::consts::LN_2).abs() < 1e-14);
Source§

impl BigFloat

Source

pub fn pow( &self, exp: &BigFloat, prec: u32, mode: RoundingMode, ) -> OxiNumResult<BigFloat>

Return self^exp at prec bits using the chosen rounding mode.

§Special cases
§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};

let two   = BigFloat::from_i64(2,  100, RoundingMode::HalfEven);
let ten   = BigFloat::from_i64(10, 100, RoundingMode::HalfEven);
let result = two.pow(&ten, 100, RoundingMode::HalfEven).expect("2^10");
assert!((result.to_f64() - 1024.0).abs() < 1e-10);
Source§

impl BigFloat

Source

pub fn log( &self, base: &BigFloat, prec: u32, mode: RoundingMode, ) -> OxiNumResult<BigFloat>

Return log_base(self) (i.e. the logarithm of self in the given base) at prec bits using the chosen rounding mode.

Computed as ln(self) / ln(base).

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};

let hundred = BigFloat::from_i64(100, 100, RoundingMode::HalfEven);
let ten     = BigFloat::from_i64(10,  100, RoundingMode::HalfEven);
let result  = hundred.log(&ten, 100, RoundingMode::HalfEven).expect("log_10(100)");
assert!((result.to_f64() - 2.0).abs() < 1e-14);
Source§

impl BigFloat

Source

pub fn sin(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return sin(self) at prec bits using the given rounding mode.

Uses argument reduction mod π/2 and a Taylor series convergent for |u| ≤ π/4.

§Errors
  • OxiNumError::Precision if |self| is too large for the internal argument-reduction step (approximately |x| > 2^62 · π/2 ≈ 7.2·10^18).
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let zero = BigFloat::zero(64);
let s = zero.sin(64, RoundingMode::HalfEven).expect("sin(0)");
assert!(s.is_zero());
Source

pub fn cos(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return cos(self) at prec bits using the given rounding mode.

§Errors

Same as BigFloat::sin.

§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let zero = BigFloat::zero(64);
let c = zero.cos(64, RoundingMode::HalfEven).expect("cos(0)");
assert_eq!(c.to_f64(), 1.0);
Source

pub fn tan(&self, prec: u32, mode: RoundingMode) -> OxiNumResult<BigFloat>

Return tan(self) at prec bits using the given rounding mode.

§Errors
§Examples
use oxinum_float::native::{BigFloat, RoundingMode};
let pi_over_4 = {
    use oxinum_float::native::pi;
    let p = pi(64).expect("pi");
    let four = BigFloat::from_i64(4, 64, RoundingMode::HalfEven);
    p.div_ref(&four).expect("div")
};
let t = pi_over_4.tan(64, RoundingMode::HalfEven).expect("tan(π/4)");
assert!((t.to_f64() - 1.0).abs() < 1e-14);

Trait Implementations§

Source§

impl Add<&BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<&BigFloat> for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<&BigFloat> for BigFloat

Source§

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

Performs the += operation. Read more
Source§

impl AddAssign for BigFloat

Source§

fn add_assign(&mut self, rhs: BigFloat)

Performs the += operation. Read more
Source§

impl Clone for BigFloat

Source§

fn clone(&self) -> BigFloat

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 BigFloat

Source§

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

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

impl Display for BigFloat

Source§

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

Hex-float-ish display. Always exact, always short:

<sign>0xb<binary-mantissa>p<exponent>

where <binary-mantissa> is the mantissa written in base 2 (MSB first). The 0xb literal prefix is intentional: it visually marks the value as “binary hex-float”, distinct from the C99 0x<hex>p<exp> format.

Non-finite values display as NaN, inf, or -inf.

Source§

impl Div<&BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<&BigFloat> for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<&BigFloat> for BigFloat

Source§

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

Performs the /= operation. Read more
Source§

impl DivAssign for BigFloat

Source§

fn div_assign(&mut self, rhs: BigFloat)

Performs the /= operation. Read more
Source§

impl From<i64> for BigFloat

Source§

fn from(n: i64) -> Self

Encodes n at 64 bits of precision with banker’s rounding.

Use BigFloat::from_i64 for explicit precision control.

Source§

impl Mul<&BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<&BigFloat> for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<&BigFloat> for BigFloat

Source§

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

Performs the *= operation. Read more
Source§

impl MulAssign for BigFloat

Source§

fn mul_assign(&mut self, rhs: BigFloat)

Performs the *= operation. Read more
Source§

impl Neg for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

fn neg(self) -> BigFloat

Performs the unary - operation. Read more
Source§

impl Neg for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

fn neg(self) -> BigFloat

Performs the unary - operation. Read more
Source§

impl OxiNum for BigFloat

Source§

fn is_zero(&self) -> bool

Returns true if this value is the canonical zero.

Delegates to the inherent BigFloat::is_zero to avoid any trait-method ambiguity.

Source§

fn is_one(&self) -> bool

Returns true if this value is exactly 1.

Uses normalized equality: a BigFloat at precision P represents 1 when its mantissa encodes 2^(P-1) and its exponent is -(P-1) (the normalization invariant pins mantissa.bit_length() == P). This is equivalent to comparing against BigFloat::from_i64(1, P, HalfEven), which produces the identical normalized representation.

The comparison must use self.precision() so that the constructed 1 has the same number of mantissa bits — two BigFloats with different precisions representing the value 1 have different mantissa/exponent pairs and would compare unequal (precision is excluded from PartialEq on the struct fields, but the mathematical value is the same; the normalized encoding, however, pins the high bit, so the bit widths must agree for field-level equality).

Source§

impl OxiSigned for BigFloat

Source§

fn signum(&self) -> Sign

Returns the sign of this value as Sign::Positive or Sign::Negative.

Delegates to the inherent sign() method (returns Sign directly) rather than the inherent signum() (returns i32) to avoid any implicit coercion and to satisfy the trait’s -> Sign return type.

Source§

fn abs(&self) -> Self

Returns the absolute value (sign forced to Sign::Positive).

Delegates to the inherent BigFloat::abs.

Source§

fn is_negative(&self) -> bool

Returns true if this value is negative.
Source§

fn is_positive(&self) -> bool

Returns true if this value is positive (and not zero).
Source§

impl PartialEq for BigFloat

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 PartialOrd for BigFloat

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 Rem<&BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &BigFloat) -> BigFloat

Performs the % operation. Read more
Source§

impl Rem<&BigFloat> for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &BigFloat) -> BigFloat

Performs the % operation. Read more
Source§

impl Rem<BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: BigFloat) -> BigFloat

Performs the % operation. Read more
Source§

impl Rem for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: BigFloat) -> BigFloat

Performs the % operation. Read more
Source§

impl RemAssign<&BigFloat> for BigFloat

Source§

fn rem_assign(&mut self, rhs: &BigFloat)

Performs the %= operation. Read more
Source§

impl RemAssign for BigFloat

Source§

fn rem_assign(&mut self, rhs: BigFloat)

Performs the %= operation. Read more
Source§

impl Sub<&BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<&BigFloat> for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<BigFloat> for &BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for BigFloat

Source§

type Output = BigFloat

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign<&BigFloat> for BigFloat

Source§

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

Performs the -= operation. Read more
Source§

impl SubAssign for BigFloat

Source§

fn sub_assign(&mut self, rhs: BigFloat)

Performs the -= operation. Read more
Source§

impl TryFrom<f64> for BigFloat

Source§

type Error = OxiNumError

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

fn try_from(x: f64) -> Result<Self, Self::Error>

Performs the conversion.

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.