[−][src]Trait fixnum::ops::RoundingDiv
Associated Types
Loading content...Required methods
pub fn rdiv(
self,
rhs: Rhs,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Rhs,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
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::{RoundingDiv, RoundMode}}; type Amount = FixedPoint<i64, U9>; fn amount(s: &str) -> FixedPoint<i64, U9> { s.parse().unwrap() } let a = amount("0.000000001"); let b = amount("1000000000"); // 1e-9 / (Ceil) 1e9 = 1e-9 assert_eq!(a.rdiv(b, RoundMode::Ceil)?, a); let zero = amount("0.0"); // 1e-9 / (Floor) 1e9 = 0 assert_eq!(a.rdiv(b, RoundMode::Floor)?, zero);
Implementations on Foreign Types
impl RoundingDiv<i8> for i8
[src]
type Output = i8
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
impl RoundingDiv<i16> for i16
[src]
type Output = i16
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
impl RoundingDiv<i32> for i32
[src]
type Output = i32
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
impl RoundingDiv<i64> for i64
[src]
type Output = i64
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
impl RoundingDiv<i128> for i128
[src]
type Output = i128
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
[src]
self,
rhs: Self,
mode: RoundMode
) -> Result<Self::Output, Self::Error>
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16
[src]
type Output = FixedPoint<i16, P>
type Error = ArithmeticError
pub 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]
type Output = FixedPoint<i32, P>
type Error = ArithmeticError
pub 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]
type Output = FixedPoint<i64, P>
type Error = ArithmeticError
pub 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>
Implementors
impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>
[src]
type Output = FixedPoint<i16, P>
type Error = ArithmeticError
pub 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]
type Output = FixedPoint<i32, P>
type Error = ArithmeticError
pub 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]
type Output = FixedPoint<i64, P>
type Error = ArithmeticError
pub fn rdiv(
self,
rhs: i64,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
[src]
self,
rhs: i64,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>