Struct AncDec
Source #[repr(C)]
pub struct AncDec {
pub int: u64,
pub frac: u64,
pub scale: u8,
pub neg: bool,
}
Expand description
64-bit fixed-point decimal (u64 int/frac, 19-digit precision, 24 bytes).
Stores integer and fractional parts as separate u64 values with an explicit scale (0-19).
Fields are pub for backward compatibility and FFI use.
§Example
use ancdec::AncDec;
let a: AncDec = "123.456".parse().unwrap();
assert_eq!(a.int, 123);
Integer part (0 to u64::MAX).
Fractional part (0 to 10^scale - 1).
Number of fractional digits (0-19).
Sign flag: true if negative.
Adds two decimals, panics on integer overflow.
Subtracts other from self, panics on integer overflow.
Multiplies two decimals, panics on overflow. Uses u256 wide arithmetic when needed.
Divides self by other, panics on division by zero. Uses u256 wide arithmetic when needed.
Checked addition. Returns None if the integer part overflows u64.
Checked subtraction. Returns None if the integer part overflows u64.
In practice, subtraction in the current design uses magnitude comparison
and cannot overflow, so this always returns Some.
Checked multiplication. Returns None if the result overflows u64 integer range.
Computes the remainder (self % other), panics on division by zero.
Returns the absolute value.
Returns the sign: 1 for positive, -1 for negative, 0 for zero.
Returns true if the value is strictly positive.
Returns true if the value is strictly negative.
Returns true if the value is zero.
Returns the smaller of self and other.
Returns the larger of self and other.
Clamps the value to the range [min, max].
Returns the square root with 18 fractional digits of precision. Panics if negative.
Raises self to the power n using binary exponentiation. Supports negative exponents.
Converts to f64 (may lose precision for large values).
Converts to i64, truncating the fractional part. Panics on overflow.
Converts to i128, truncating the fractional part.
Rounds to the given number of decimal places using the specified mode.
Returns the largest integer less than or equal to self.
Returns the smallest integer greater than or equal to self.
Returns the integer part, truncating toward zero.
Returns the fractional part only.
The maximum representable value.
Parses any Display type into an AncDec using a stack buffer (no heap allocation).
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the + operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the + operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the + operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the + operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
Performs copy-assignment from
source.
Read more
Formats the value using the given formatter.
Read moreSource§Default trait: AncDec::default() returns ZERO
Returns the “default value” for a type.
Read moreSource§Display trait: enables format!, println!, to_string()
Formats the value using the given formatter.
Read more
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the / operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the / operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the / operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the / operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
Source§Available on crate feature dec64 only.
Lossless widening from AncDec (u64) to AncDec128 (u128)
Converts to this type from the input type.
Source§Available on crate feature dec32 only.
Lossless widening from AncDec32 (u32) to AncDec (u64)
Converts to this type from the input type.
Source§Available on crate feature dec8 only.
Lossless widening from AncDec8 (u8) to AncDec (u64)
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Source§FromStr trait: enables "123.45".parse::<AncDec>()
The associated error which can be returned from parsing.
Parses a string
s to return a value of this type.
Read moreSource§Hash trait: enables use in HashMap/HashSet
Normalizes trailing zeros so 1.0 == 1.00 have same hash
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the * operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the * operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the * operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the * operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
Source§Ord trait: enables <, >, sort(), min(), max()
Compares and returns the maximum of two values.
Read more
Compares and returns the minimum of two values.
Read more
Restrict a value to a certain interval.
Read moreSource§PartialEq trait: enables ==, !=
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Source§PartialOrd trait: enables <, > comparisons
This method returns an ordering between
self and
other values if one exists.
Read more
Tests less than (for
self and
other) and is used by the
< operator.
Read more
Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more
Tests greater than (for
self and
other) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more
Takes an iterator and generates Self from the elements by multiplying
the items.
Source§Product trait: enables iter.product::<AncDec>()
Takes an iterator and generates Self from the elements by multiplying
the items.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the % operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the % operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the % operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the % operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the % operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the - operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the - operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
Source§Available on crate features dec64 and dec128 only.
The resulting type after applying the - operator.
Source§Available on crate features dec32 and dec64 only.
The resulting type after applying the - operator.
Source§Available on crate features dec8 and dec64 only.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
Takes an iterator and generates Self from the elements by “summing up”
the items.
Source§Sum trait: enables iter.sum::<AncDec>()
Takes an iterator and generates Self from the elements by “summing up”
the items.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Source§Eq trait: marker for total equality (no NaN)
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.