[][src]Trait fixnum::ops::RoundingMul

pub trait RoundingMul<Rhs = Self> {
    type Output;
    type Error;
    pub fn rmul(
        self,
        rhs: Rhs,
        mode: RoundMode
    ) -> Result<Self::Output, Self::Error>; }

Associated Types

Loading content...

Required methods

pub fn rmul(
    self,
    rhs: Rhs,
    mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]

Checked rounded multiplication. Returns Err on overflow. Because of provided RoundMode it's possible to perform across the FixedPoint values.

use fixnum::{FixedPoint, typenum::U9, ops::{RoundingMul, RoundMode}};

type Amount = FixedPoint<i64, U9>;

fn amount(s: &str) -> FixedPoint<i64, U9> { s.parse().unwrap() }

let a = amount("0.000000001");
let b = amount("0.000000002");
// 1e-9 * (Ceil) 2e-9 = 1e-9
assert_eq!(a.rmul(b, RoundMode::Ceil)?, a);
assert_eq!(b.rmul(a, RoundMode::Ceil)?, a);
let zero = amount("0.0");
// 1e-9 * (Floor) 2e-9 = 0
assert_eq!(a.rmul(b, RoundMode::Floor)?, zero);
assert_eq!(b.rmul(a, RoundMode::Floor)?, zero);
Loading content...

Implementors

impl<P: Precision> RoundingMul<FixedPoint<i16, P>> for FixedPoint<i16, P>[src]

type Output = FixedPoint<i16, P>

type Error = ArithmeticError

impl<P: Precision> RoundingMul<FixedPoint<i32, P>> for FixedPoint<i32, P>[src]

type Output = FixedPoint<i32, P>

type Error = ArithmeticError

impl<P: Precision> RoundingMul<FixedPoint<i64, P>> for FixedPoint<i64, P>[src]

type Output = FixedPoint<i64, P>

type Error = ArithmeticError

Loading content...