#[repr(transparent)]
pub struct Decimal128 { /* private fields */ }
Expand description

A 128-bit decimal floating-point number.

Additional operations are defined as methods on the Context type.

For convenience, Decimal128 overloads many of the standard Rust operators. For example, you can use the standard + operator to add two values together:

use dec::Decimal128;
let a = Decimal128::from(1);
let b = Decimal128::from(2);
assert_eq!(a + b, Decimal128::from(3));

These overloaded operators implicitly construct a single-use default context, which has some performance overhead. For maximum performance when performing operations in bulk, use a long-lived context that you construct yourself.

Implementations

The value that represents Not-a-Number (NaN).

The value that represents zero.

The value that represents one.

Creates a number from its representation as a little-endian byte array.

Creates a number from its representation as a big-endian byte array.

Creates a number from its representation as a byte array in the native endianness of the target platform.

Returns the memory representation of the number as a byte array in little-endian order.

Returns the memory representation of the number as a byte array in big-endian order.

Returns the memory representation of the number as a byte array in the native endianness of the target platform.

Classifies the number.

Computes the number of significant digits in the number.

If the number is zero or infinite, returns 1. If the number is a NaN, returns the number of digits in the payload.

Computes the coefficient of the number.

If the number is a special value (i.e., NaN or infinity), returns zero.

Returns the individual digits of the coefficient in 8-bit, unpacked binary-coded decimal format.

Computes the exponent of the number.

Returns an equivalent number whose encoding is guaranteed to be canonical.

Reports whether the encoding of the number is canonical.

Reports whether the number is finite.

A finite number is one that is neither infinite nor a NaN.

Reports whether the number is positive or negative infinity.

Reports whether the number is an integer.

An integer is a decimal number that is finite and has an exponent of zero.

Reports whether the number is a valid argument for logical operations.

A number is a valid argument for logical operations if it is a nonnegative integer where each digit is either zero or one.

Reports whether the number is a NaN.

Reports whether the number is less than zero and not a NaN.

Reports whether the number is normal.

A normal number is finite, non-zero, and not subnormal.

Reports whether the number is greater than zero and not a NaN.

Reports whether the number is a signaling NaN.

Reports whether the number has a sign of 1.

Note that zeros and NaNs may have a sign of 1.

Reports whether the number is subnormal.

A subnormal number is finite, non-zero, and has magnitude less than 10emin.

Reports whether the number is positive or negative zero.

Reports whether the quantum of the number matches the quantum of rhs.

Quantums are considered to match if the numbers have the same exponent, are both NaNs, or both infinite.

Determines the ordering of this number relative to rhs, using the total order predicate defined in IEEE 754-2008.

For a brief description of the ordering, consult f32::total_cmp.

Returns a string of the number in standard notation, i.e. guaranteed to not be scientific notation.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

Performs the %= operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

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.