FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Decimal

    struct · ferroui-base · v0.5.0

    struct Decimal
    

    An exact decimal number.

    View source

    Members

    ZERO

    const ZERO: Decimal
    

    The number zero.

    Source

    ONE

    const ONE: Decimal
    

    The number one.

    Source

    MAX_VALUE

    const MAX_VALUE: Decimal
    

    The largest value: 79,228,162,514,264,337,593,543,950,335.

    Source

    MIN_VALUE

    const MIN_VALUE: Decimal
    

    The smallest value: -79,228,162,514,264,337,593,543,950,335.

    Source

    from_parts

    fn from_parts(mantissa: u128, scale: u8, negative: bool) -> Decimal
    

    A decimal of mantissa / 10^scale, negated when negative.

    Panics when the mantissa has more than 96 bits or the scale is greater than 28.

    Source

    mantissa

    fn mantissa(self: &Self) -> u128
    

    The 96-bit integer that, divided by 10^scale, is the magnitude.

    Source

    scale

    fn scale(self: &Self) -> u8
    

    The number of digits after the decimal point (0 to 28).

    Source

    is_sign_negative

    fn is_sign_negative(self: &Self) -> bool
    

    Whether the sign bit is set. Negative zero has it set and is equal to zero.

    Source

    is_zero

    fn is_zero(self: &Self) -> bool
    

    Whether the value is zero (of any scale and sign).

    Source

    max

    fn max(self: Self, other: Decimal) -> Decimal
    

    The larger of two values (C# Math.Max): of two equal values the first, which matters for their scales.

    Source

    min

    fn min(self: Self, other: Decimal) -> Decimal
    

    The smaller of two values (C# Math.Min): of two equal values the second, which matters for their scales.

    Source

    checked_add

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

    The sum, or None when it is out of range.

    Source

    checked_sub

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

    The difference, or None when it is out of range.

    Source

    checked_mul

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

    The product, or None when it is out of range. The scale is the sum of the scales, rounded to 28 digits after the point when it is larger, as the managed type multiplies.

    Source

    checked_div

    fn checked_div(self: Self, other: Decimal) -> Option<Decimal>
    

    The quotient, or None when it is out of range. Panics when other is zero.

    Source

    to_f64

    fn to_f64(self: &Self) -> f64
    

    The nearest double-precision number (the explicit conversion of the managed type to a double).

    Source

    to_f32

    fn to_f32(self: &Self) -> f32
    

    The nearest single-precision number (the explicit conversion of the managed type to a float): the double of the value, narrowed.

    Source

    round_to_integer

    fn round_to_integer(self: &Self) -> i128
    

    The value rounded to an integer, midpoints to even (Decimal.Round with no decimals, which the conversions of the managed runtime to the integer types apply before their range check).

    Source

    from_f64

    fn from_f64(value: f64) -> Decimal
    

    The decimal of a double-precision number, rounded to 15 significant digits (the explicit conversion of a double to the managed type).

    Panics when the number is not finite or is outside the value range.

    Source

    from_f32

    fn from_f32(value: f32) -> Decimal
    

    The decimal of a single-precision number, rounded to 7 significant digits (the explicit conversion of a float to the managed type).

    Panics when the number is not finite or is outside the value range.

    Source

    try_from_f32

    fn try_from_f32(value: f32) -> Option<Decimal>
    

    from_f32, with None where it panics.

    Source

    try_from_f64

    fn try_from_f64(value: f64) -> Option<Decimal>
    

    from_f64, with None where it panics.

    Source

    parse

    fn parse(s: &str) -> Result<Decimal, NumberParseError>
    

    Parses text of the invariant culture with the Number styles: leading and trailing white space, a leading or trailing sign, a decimal point and group separators.

    Source

    try_parse

    fn try_parse(s: &str) -> Option<Decimal>
    

    Decimal::parse without the reason of a failure.

    Source

    parse_with

    fn parse_with(s: &str, styles: NumberStyles, provider: Option<&NumberFormatInfo>) -> Result<Decimal, NumberParseError>
    

    Parses text with the given styles and format information (C# decimal.Parse(string, NumberStyles, IFormatProvider)). Without a provider the format information of the current culture is used.

    Styles that are not defined, and the hexadecimal and binary styles, are an error (NumberParseError::InvalidStyle).

    Source

    try_parse_with

    fn try_parse_with(s: &str, styles: NumberStyles, provider: Option<&NumberFormatInfo>) -> Option<Decimal>
    

    Decimal::parse_with without the reason of a failure.

    Source

    to_string_with

    fn to_string_with(self: &Self, format: &str, provider: Option<&NumberFormatInfo>) -> Result<String, FormatError>
    

    Formats the value with a standard or custom numeric format string (C# ToString(string, IFormatProvider)). Without a provider the format information of the current culture is used.

    Source

    to_string_provider

    fn to_string_provider(self: &Self, provider: &NumberFormatInfo) -> String
    

    Formats the value in the general format with the given format information (C# ToString(IFormatProvider)).

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ResourceKeyObject
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Copy
    • StructuralPartialEq
    • PartialEq
    • Eq
    • PartialOrd
    • Ord
    • Hash
    • MarkupTyped
    • Default
    • Display
    • Debug
    • FromStr
    • From<i8>
    • From<i16>
    • From<i32>
    • From<i64>
    • From<isize>
    • From<u8>
    • From<u16>
    • From<u32>
    • From<u64>
    • From<usize>
    • Neg
    • Add
    • Sub
    • Div
    • AddAssign
    • SubAssign
    • ValueTypeRegistration

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.