Function cfg_primitives::conversion::balance_to_fixed_point
source · pub fn balance_to_fixed_point<FixedPoint: FixedPointNumber<Inner = IntoBalance>, IntoBalance: BaseArithmetic + Copy>(
balance: IntoBalance,
decimals: usize
) -> Result<FixedPoint, ArithmeticError>
Expand description
Transform a balance to a fixed point number.
Inverse operation of fixed_point_to_balance
use cfg_primitives::conversion::balance_to_fixed_point;
assert_ok!(balance_to_fixed_point(2_123_456_789, 0), FixedU64::from_inner(2_123_456_789_000_000_000));
assert_ok!(balance_to_fixed_point(2_123_456_789, 3), FixedU64::from_inner(2_123_456_789_000_000));
assert_ok!(balance_to_fixed_point(2_123_456_789, 6), FixedU64::from_inner(2_123_456_789_000));
assert_ok!(balance_to_fixed_point(2_123_456_789, 9), FixedU64::from_inner(2_123_456_789));
assert_ok!(balance_to_fixed_point(2_123_456_789, 12), FixedU64::from_inner(2_123_456));
assert_ok!(balance_to_fixed_point(2_123_456_789, 15), FixedU64::from_inner(2_123));
assert_ok!(balance_to_fixed_point(2_123_456_789, 18), FixedU64::from_inner(2));