Function signed_fixed_to_decimal

Source
pub fn signed_fixed_to_decimal(num: i128, decimals: u8) -> Option<Decimal>
Expand description

Convert signed fixed-point value to [Decimal].

Returns None if it cannot be represented as a [Decimal].

ยงExamples

use gmsol::utils::signed_fixed_to_decimal;
use rust_decimal_macros::dec;

assert_eq!(
    signed_fixed_to_decimal(-100_451_723_195, 6),
    Some(dec!(-100_451.723195)),
);

assert_eq!(
    signed_fixed_to_decimal(i128::MIN, 10),
    None,
);