Skip to main content

fi128

Struct fi128 

Source
pub struct fi128(pub i128);
Expand description

Signed Fractional Integer of the unit range.

Note: in the future we want to make the inner type private, but not currently because we don’t have stable const traits.

Tuple Fields§

§0: i128

Trait Implementations§

Source§

impl Add for fi128

Source§

type Output = fi128

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for fi128

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl BitAnd for fi128

Source§

type Output = fi128

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
Source§

impl BitAndAssign for fi128

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for fi128

Source§

type Output = fi128

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for fi128

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for fi128

Source§

type Output = fi128

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
Source§

impl BitXorAssign for fi128

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for fi128

Source§

fn clone(&self) -> fi128

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 Copy for fi128

Source§

impl Debug for fi128

Source§

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

Converts to a base 10 string representation

fiN::ONE and fiN::NEG_ONE are special cased to “1.0” and “-1.0” respectively.

Source§

impl Default for fi128

Source§

fn default() -> fi128

Returns the “default value” for a type. Read more
Source§

impl Display for fi128

Source§

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

Converts to a base 10 string representation

fiN::ONE and fiN::NEG_ONE are special cased to “1.0” and “-1.0” respectively.

Source§

impl Div for fi128

Source§

type Output = fi128

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<i128> for fi128

Source§

type Output = fi128

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i128) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign for fi128

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl DivAssign<i128> for fi128

Source§

fn div_assign(&mut self, rhs: i128)

Performs the /= operation. Read more
Source§

impl Eq for fi128

Source§

impl Fracint for fi128

Source§

const BITS: usize

The number of bits in this type
Source§

const MAX: Self

The maximum value representable by Self
Source§

const MIN: Self

The minimum value representable by Self
Source§

const NEG_ONE: Self

A numerical value of negative one. Read more
Source§

const ONE: Self

For fiN, ONE and MAX are the same. Prefer to use MAX when wanting to emphasize the true numeric bounds or ordered maximum, and instead use ONE for numeric values.
Source§

const SIGNED: bool = true

If this type is signed
Source§

const ULP: Self

One positive Unit in the Last Place
Source§

const ZERO: Self

Zero.
Source§

type Int = i128

This is only for workarounds, to make this better we would need a refined trait for normal integers.
Source§

fn from_int(x: Self::Int) -> Self

Casts from the Self::Int type
Source§

fn as_int(self) -> Self::Int

Casts to the Self::Int type
Source§

fn overflowing_abs(self) -> (Self, bool)

Returns a tuple of self.wrapping_abs() along with a boolean indicating whether an overflow happened.
Source§

fn wrapping_neg(self) -> Self

Wrapping negation of self. Read more
Source§

fn overflowing_neg(self) -> (Self, bool)

Returns a tuple of self.wrapping_neg() along with a boolean indicating whether an overflow happened.
Source§

fn saturating_neg(self) -> Self

Saturating negation of self. It behaves the same way as wrapping_neg except Self::MIN.saturating_neg() -> Self::ONE
Source§

fn saturating_inv(self) -> i128

Saturating inversion of self. It has the special cases Read more
Source§

fn wrapping_add(self, rhs: Self) -> Self

Wrapping (modular) addition. Read more
Source§

fn overflowing_add(self, rhs: Self) -> (Self, bool)

Returns a tuple of self.wrapping_add(rhs) along with a boolean indicating whether an overflow happened. Note that if self.wrapping_add(rhs) == fiN::MIN, it is counted as overflow.
Source§

fn saturating_add(self, rhs: Self) -> Self

Saturating addition. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing.
Source§

fn wrapping_sub(self, rhs: Self) -> Self

Wrapping (modular) subtraction. Read more
Source§

fn overflowing_sub(self, rhs: Self) -> (Self, bool)

Returns a tuple of self.wrapping_sub(rhs) along with a boolean indicating whether an overflow happened. Note that if self.wrapping_sub(rhs) == fiN::MIN, it is counted as overflow.
Source§

fn saturating_sub(self, rhs: Self) -> Self

Saturating subtraction. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing.
Source§

fn wrapping_mul(self, rhs: Self) -> Self

Wrapping fracint multiplication. Read more
Source§

fn overflowing_mul(self, rhs: Self) -> (Self, bool)

Returns a tuple of self.wrapping_mul(rhs) along with a boolean indicating whether an overflow happened. Read more
Source§

fn saturating_mul(self, rhs: Self) -> Self

Saturating fracint multiplication. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing.
Source§

fn saturating_mul_int(self, rhs: i128) -> Self

Saturating fracint multiplication with an integer. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing.
Source§

fn saturating_div(self, rhs: Self) -> Self

Saturating fracint division. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing. Read more
Source§

fn saturating_div_int(self, rhs: Self::Int) -> Self

Saturating fracint division with an integer. Saturates at the numeric bounds fiN::NEG_ONE and fiN::ONE instead of overflowing. Read more
Source§

fn sqrt_fast(self) -> Self

Fast way of calculating the square root to within a few ULPs of the true value.
Source§

fn from_f32(f: f32) -> Option<Self>

Converts from an f32 to Self. Returns None if the absolute value is greater than 1.0.
Source§

fn from_f64(f: f64) -> Option<Self>

Converts from an f64 to Self. Returns None if the absolute value is greater than 1.0.
Source§

fn to_f32(self) -> f32

Converts to an f32
Source§

fn to_f64(self) -> f64

Converts to an f64
Source§

fn is_zero(self) -> bool

Source§

fn is_negative(self) -> bool

Source§

fn is_positive(self) -> bool

Source§

fn signum(self) -> Self

Returns a value representing the sign of self. Read more
Source§

fn wrapping_abs(self) -> Self

Wrapping absolute value of self. Read more
Source§

fn checked_abs(self) -> Option<Self>

Same as overflowing_abs except it returns None on overflow
Source§

fn saturating_abs(self) -> Self

Saturating absolute value of self. It behaves the same way as wrapping_abs except Self::MIN.saturating_abs() -> Self::ONE
Source§

fn checked_neg(self) -> Option<Self>

Same as overflowing_neg except it returns None on overflow
Source§

fn checked_add(self, rhs: Self) -> Option<Self>

Same as overflowing_add except it returns None on overflow
Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Same as overflowing_sub except it returns None on overflow
Source§

fn checked_mul(self, rhs: Self) -> Option<Self>

Same as overflowing_mul except it returns None on overflow
Source§

fn sqrt_simple_bisection(self) -> Self

Slow way of calculating the truncated square root using bisection. This will always underestimate the square root, with about as much bit error as the number of leading zero bits.
Source§

impl FracintHalf for fi128

Source§

type Half = fi64

The half-sized version of Self
Source§

fn split(self) -> (fi64, fi64)

Returns half sized low and high parts. The high part is effectively a truncated version of self, and the low part is the remainder.
Source§

fn truncate(self) -> fi64

Truncates self down to a half sized type with the same value except with less than 1 ULP of error.
Source§

impl From<fi64> for fi128

Source§

fn from(x: fi64) -> Self

Lossless conversion

Source§

impl FromStr for fi128

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Conversion from a string representation.

The input can start with a ‘-’ to make the output negative. Then it can optionally start with a “0b”, “0o”, or a “0x” prefix to use radix 2, 8, or 16 respectively, otherwise it is parsed as radix 10. There must be an integer part with digits in the correct radix. If including the fraction, a ‘.’ followed by one more digits in the correct radix should be added. Finally, an exponent can be added by ‘e’ or ‘p’ (except radix 16 which must use ‘p’) and then a number in the same radix is used. The exponent is applied as * radix^exponent before round-to-even. ’_’s can be used throughout the integer, fraction, and exponent parts as long as one term is not all underspaces.

s can be arbitrarily long but significance changes stops after a number of chars.

The number must be in the range (-1.0,1.0) or else an overflow error is returned. 1.0 is special cased to map to fiN::ONE' even though it is not exactly representable, and -1.0 is special cased to map to fiN::NEG_ONEto avoid introducingfiN::MIN`.

See the [FracintParseError] documentation for parsing errors and examples.

Source§

type Err = FracintSerdeError

The associated error which can be returned from parsing.
Source§

impl Hash for fi128

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for fi128

Source§

type Output = fi128

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i128> for fi128

Source§

type Output = fi128

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i128) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign for fi128

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl MulAssign<i128> for fi128

Source§

fn mul_assign(&mut self, rhs: i128)

Performs the *= operation. Read more
Source§

impl Neg for fi128

Source§

type Output = fi128

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Not for fi128

Source§

type Output = fi128

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl Ord for fi128

Source§

fn cmp(&self, other: &fi128) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for fi128

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for fi128

Source§

fn partial_cmp(&self, other: &fi128) -> 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 Product for fi128

Source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<'a> Product<&'a fi128> for fi128

Source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Shl<usize> for fi128

Source§

type Output = fi128

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: usize) -> Self

Performs the << operation. Read more
Source§

impl ShlAssign<usize> for fi128

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl Shr<usize> for fi128

Source§

type Output = fi128

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> Self

Performs the >> operation. Read more
Source§

impl ShrAssign<usize> for fi128

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl StructuralPartialEq for fi128

Source§

impl Sub for fi128

Source§

type Output = fi128

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for fi128

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Sum for fi128

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a fi128> for fi128

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.

Auto Trait Implementations§

§

impl Freeze for fi128

§

impl RefUnwindSafe for fi128

§

impl Send for fi128

§

impl Sync for fi128

§

impl Unpin for fi128

§

impl UnsafeUnpin for fi128

§

impl UnwindSafe for fi128

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 = !

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.