Trait fixnum::ops::RoundingDiv [−][src]
pub trait RoundingDiv<Rhs = Self> { type Output; type Error; fn rdiv(
self,
rhs: Rhs,
mode: RoundMode
) -> Result<Self::Output, Self::Error>; }
Associated Types
Required methods
fn rdiv(self, rhs: Rhs, mode: RoundMode) -> Result<Self::Output, Self::Error>
[src]
fn rdiv(self, rhs: Rhs, mode: RoundMode) -> Result<Self::Output, Self::Error>
[src]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
impl RoundingDiv<i8> for i8
[src]
impl RoundingDiv<i8> for i8
[src]impl RoundingDiv<i16> for i16
[src]
impl RoundingDiv<i16> for i16
[src]impl RoundingDiv<i32> for i32
[src]
impl RoundingDiv<i32> for i32
[src]impl RoundingDiv<i64> for i64
[src]
impl RoundingDiv<i64> for i64
[src]impl RoundingDiv<i128> for i128
[src]
impl RoundingDiv<i128> for i128
[src]impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16
[src]type Output = FixedPoint<i16, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: FixedPoint<i16, P>,
mode: RoundMode
) -> Result<FixedPoint<i16, P>, ArithmeticError>
[src]
self,
rhs: FixedPoint<i16, P>,
mode: RoundMode
) -> Result<FixedPoint<i16, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for i32
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for i32
[src]type Output = FixedPoint<i32, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: FixedPoint<i32, P>,
mode: RoundMode
) -> Result<FixedPoint<i32, P>, ArithmeticError>
[src]
self,
rhs: FixedPoint<i32, P>,
mode: RoundMode
) -> Result<FixedPoint<i32, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for i64
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for i64
[src]type Output = FixedPoint<i64, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: FixedPoint<i64, P>,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
[src]
self,
rhs: FixedPoint<i64, P>,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for i128
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for i128
[src]This is supported on crate feature
i128
only.type Output = FixedPoint<i128, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: FixedPoint<i128, P>,
mode: RoundMode
) -> Result<FixedPoint<i128, P>, ArithmeticError>
[src]
self,
rhs: FixedPoint<i128, P>,
mode: RoundMode
) -> Result<FixedPoint<i128, P>, ArithmeticError>
Implementors
impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>
[src]
impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>
[src]type Output = FixedPoint<i16, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: i16,
mode: RoundMode
) -> Result<FixedPoint<i16, P>, ArithmeticError>
[src]
self,
rhs: i16,
mode: RoundMode
) -> Result<FixedPoint<i16, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<i32> for FixedPoint<i32, P>
[src]
impl<P: Precision> RoundingDiv<i32> for FixedPoint<i32, P>
[src]type Output = FixedPoint<i32, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: i32,
mode: RoundMode
) -> Result<FixedPoint<i32, P>, ArithmeticError>
[src]
self,
rhs: i32,
mode: RoundMode
) -> Result<FixedPoint<i32, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<i64> for FixedPoint<i64, P>
[src]
impl<P: Precision> RoundingDiv<i64> for FixedPoint<i64, P>
[src]type Output = FixedPoint<i64, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: i64,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
[src]
self,
rhs: i64,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<i128> for FixedPoint<i128, P>
[src]
impl<P: Precision> RoundingDiv<i128> for FixedPoint<i128, P>
[src]This is supported on crate feature
i128
only.type Output = FixedPoint<i128, P>
type Error = ArithmeticError
fn rdiv(
self,
rhs: i128,
mode: RoundMode
) -> Result<FixedPoint<i128, P>, ArithmeticError>
[src]
self,
rhs: i128,
mode: RoundMode
) -> Result<FixedPoint<i128, P>, ArithmeticError>
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for FixedPoint<i16, P>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for FixedPoint<i16, P>
[src]type Output = FixedPoint<i16, P>
type Error = ArithmeticError
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for FixedPoint<i32, P>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for FixedPoint<i32, P>
[src]type Output = FixedPoint<i32, P>
type Error = ArithmeticError
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for FixedPoint<i64, P>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for FixedPoint<i64, P>
[src]type Output = FixedPoint<i64, P>
type Error = ArithmeticError
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for FixedPoint<i128, P>
[src]
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for FixedPoint<i128, P>
[src]This is supported on crate feature
i128
only.