Skip to main content

FixedPointOps

Trait FixedPointOps 

Source
pub trait FixedPointOps<const DECIMALS: u8>: MulDiv + Num {
    const UNIT: Self;

    // Required method
    fn checked_pow_fixed(&self, exponent: &Self) -> Option<Self>;
}
Expand description

Number type with the required properties for implementing Fixed.

Required Associated Constants§

Source

const UNIT: Self

The unit value (i.e. the value “one”) which is expected to be pow(10, DECIMALS).

Required Methods§

Source

fn checked_pow_fixed(&self, exponent: &Self) -> Option<Self>

Fixed point power.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<const DECIMALS: u8> FixedPointOps<DECIMALS> for u64

Source§

fn checked_pow_fixed(&self, exponent: &Self) -> Option<Self>

Fixed point power.

§Notes

The code that calculates exponents behaves inconsistently depending on whether the exponent is a whole unit or not. Therefore, to avoid issues, we should use only unit exponents until we implement better algorithms.

Source§

const UNIT: Self

Source§

impl<const DECIMALS: u8> FixedPointOps<DECIMALS> for u128

Available on crate feature u128 only.
Source§

fn checked_pow_fixed(&self, exponent: &Self) -> Option<Self>

Fixed point power.

§Notes

The code that calculates exponents behaves inconsistently depending on whether the exponent is a whole unit or not. Therefore, to avoid issues, we should use only unit exponents until we implement better algorithms.

Source§

const UNIT: Self

Implementors§