pub trait RoundingDiv<Rhs = Self> {
    type Output;
    type Error;

    fn rdiv(
        self,
        rhs: Rhs,
        mode: RoundMode
    ) -> Result<Self::Output, Self::Error>; }
Expand description

Rounding division.

Required Associated Types

Result of division.

Usually ArithmeticError.

Required Methods

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values.

use fixnum::{FixedPoint, typenum::U9, ops::{Zero, RoundingDiv, RoundMode::*}};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "0.000000001".parse()?;
let b: Amount = "1000000000".parse()?;
// 1e-9 / (Ceil) 1e9 = 1e-9
assert_eq!(a.rdiv(b, Ceil)?, a);
// 1e-9 / (Floor) 1e9 = 0
assert_eq!(a.rdiv(b, Floor)?, Amount::ZERO);

Implementations on Foreign Types

Implementors