Skip to main content

Module decimal

Module decimal 

Source
Expand description

Maximum and minimum values for Decimal256, Decimal128, Decimal64 and Decimal32.

Also provides functions to validate if a given decimal value is within the valid range of the decimal type.

Modulesยง

sealed ๐Ÿ”’

Macrosยง

decimal_native ๐Ÿ”’

Structsยง

DigitBuffer ๐Ÿ”’
The formatted digits of a decimal native value, with its sign

Constantsยง

DECIMAL32_DEFAULT_SCALE
The default scale for [DataType::Decimal32] values
DECIMAL32_MAX_PRECISION
The maximum precision for [DataType::Decimal32] values
DECIMAL32_MAX_SCALE
The maximum scale for [DataType::Decimal32] values
DECIMAL64_DEFAULT_SCALE
The default scale for [DataType::Decimal64] values
DECIMAL64_MAX_PRECISION
The maximum precision for [DataType::Decimal64] values
DECIMAL64_MAX_SCALE
The maximum scale for [DataType::Decimal64] values
DECIMAL128_MAX_PRECISION
The maximum precision for [DataType::Decimal128] values
DECIMAL128_MAX_SCALE
The maximum scale for [DataType::Decimal128] values
DECIMAL256_MAX_PRECISION
The maximum precision for [DataType::Decimal256] values
DECIMAL256_MAX_SCALE
The maximum scale for [DataType::Decimal256] values
DECIMAL_DEFAULT_SCALE
The default scale for [DataType::Decimal128] and [DataType::Decimal256] values
MAX_DECIMAL32_FOR_EACH_PRECISION
MAX_DECIMAL32_FOR_EACH_PRECISION[p] holds the maximum i32 value that can be stored in Decimal32 value of precision p.
MAX_DECIMAL64_FOR_EACH_PRECISION
MAX_DECIMAL64_FOR_EACH_PRECISION[p] holds the maximum i64 value that can be stored in Decimal64 value of precision p.
MAX_DECIMAL128_FOR_EACH_PRECISION
MAX_DECIMAL128_FOR_EACH_PRECISION[p] holds the maximum i128 value that can be stored in Decimal128 value of precision p.
MAX_DECIMAL256_FOR_EACH_PRECISION
MAX_DECIMAL256_FOR_EACH_PRECISION[p] holds the maximum i256 value that can be stored in a Decimal256 value of precision p.
MAX_DECIMAL_VALUE_LEN ๐Ÿ”’
The length of the longest decimal native value when formatted: i256::MIN has 77 digits and a sign
MIN_DECIMAL32_FOR_EACH_PRECISION
MIN_DECIMAL32_FOR_EACH_PRECISION[p] holds the minimum value that can be stored in a Decimal32 value of precision p.
MIN_DECIMAL64_FOR_EACH_PRECISION
MIN_DECIMAL64_FOR_EACH_PRECISION[p] holds the minimum i64 value that can be stored in a Decimal64 value of precision p.
MIN_DECIMAL128_FOR_EACH_PRECISION
MIN_DECIMAL_FOR_EACH_PRECISION[p] holds the minimum i128 value that can be stored in a Decimal128 value of precision p.
MIN_DECIMAL256_FOR_EACH_PRECISION
MIN_DECIMAL256_FOR_EACH_PRECISION[p] holds the minimum i256 value that can be stored in a Decimal256 value of precision p.

Traitsยง

DecimalNativeType
The native value of a decimal type: i32, i64, i128 or i256

Functionsยง

format_decimal
Formats the unscaled decimal value with scale fractional digits: the decimal point is inserted scale digits from the right, with leading zeros as needed, and a negative scale appends zeros instead. The value is always formatted in full, whatever its precision.
format_decimal_str
Formats a decimal string given the scale.
format_decimal_str_internal ๐Ÿ”’
Formats value_str as write_decimal_str does, into a String with enough capacity to avoid reallocation
is_validate_decimal32_precision
Returns true if the specified i32 value can be properly interpreted as a Decimal32 number with precision precision
is_validate_decimal64_precision
Returns true if the specified i64 value can be properly interpreted as a Decimal64 number with precision precision
is_validate_decimal256_precision
Return true if the specified i256 value can be properly interpreted as a Decimal256 number with precision precision
is_validate_decimal_precision
Returns true if the specified i128 value can be properly interpreted as a Decimal128 number with precision precision
validate_decimal32_precision
Validates that the specified i32 value can be properly interpreted as a Decimal32 number with precision precision
validate_decimal64_precision
Validates that the specified i64 value can be properly interpreted as a Decimal64 number with precision precision
validate_decimal256_precision
Validates that the specified i256 of value can be properly interpreted as a Decimal256 number with precision precision
validate_decimal_precision
Validates that the specified i128 value can be properly interpreted as a Decimal128 number with precision precision
write_decimal
Like format_decimal, but writes the result to f instead of returning a new String.
write_decimal_str ๐Ÿ”’
Writes value_str, the digits of an unscaled decimal value with an optional leading -, to f as a decimal with scale fractional digits: the decimal point is inserted scale digits from the right, with leading zeros as needed, and a negative scale appends zeros instead. The value is always written in full, whatever its precision.