Trait rug::ops::RemRounding[][src]

pub trait RemRounding<Rhs = Self> {
    type Output;
    fn rem_trunc(self, rhs: Rhs) -> Self::Output;
fn rem_ceil(self, rhs: Rhs) -> Self::Output;
fn rem_floor(self, rhs: Rhs) -> Self::Output;
fn rem_euc(self, rhs: Rhs) -> Self::Output; }

Rounding variants of the remainder operation.

Examples

use rug::ops::RemRounding;
struct I(i32);
impl RemRounding<i32> for I {
    type Output = i32;
    fn rem_trunc(self, rhs: i32) -> i32 {
        self.0 % rhs
    }
    fn rem_ceil(self, rhs: i32) -> i32 {
        let r = self.0 % rhs;
        let change = if rhs > 0 { r > 0 } else { r < 0 };
        if change {
            r - rhs
        } else {
            r
        }
    }
    fn rem_floor(self, rhs: i32) -> i32 {
        let r = self.0 % rhs;
        let change = if rhs > 0 { r < 0 } else { r > 0 };
        if change {
            r + rhs
        } else {
            r
        }
    }
    fn rem_euc(self, rhs: i32) -> i32 {
        let r = self.0 % rhs;
        if r < 0 {
            if rhs < 0 {
                r - rhs
            } else {
                r + rhs
            }
        } else {
            r
        }
    }
}
assert_eq!(I(-10).rem_trunc(-3), -1);
assert_eq!(I(-10).rem_ceil(-3), 2);
assert_eq!(I(-10).rem_floor(-3), -1);
assert_eq!(I(-10).rem_euc(-3), 2);

Associated Types

type Output[src]

The resulting type from the remainder operation.

Loading content...

Required methods

fn rem_trunc(self, rhs: Rhs) -> Self::Output[src]

Finds the remainder when the quotient is rounded towards zero.

fn rem_ceil(self, rhs: Rhs) -> Self::Output[src]

Finds the remainder when the quotient is rounded up.

fn rem_floor(self, rhs: Rhs) -> Self::Output[src]

Finds the remainder when the quotient is rounded down.

fn rem_euc(self, rhs: Rhs) -> Self::Output[src]

Finds the positive remainder from Euclidean division.

Loading content...

Implementations on Foreign Types

impl RemRounding<i8> for i8[src]

type Output = i8

impl RemRounding<&'_ i8> for i8[src]

type Output = <i8 as RemRounding>::Output

impl RemRounding<i8> for &i8[src]

type Output = <i8 as RemRounding>::Output

impl RemRounding<&'_ i8> for &i8[src]

type Output = <i8 as RemRounding>::Output

impl RemRounding<i16> for i16[src]

type Output = i16

impl RemRounding<&'_ i16> for i16[src]

type Output = <i16 as RemRounding>::Output

impl RemRounding<i16> for &i16[src]

type Output = <i16 as RemRounding>::Output

impl RemRounding<&'_ i16> for &i16[src]

type Output = <i16 as RemRounding>::Output

impl RemRounding<i32> for i32[src]

type Output = i32

impl RemRounding<&'_ i32> for i32[src]

type Output = <i32 as RemRounding>::Output

impl RemRounding<i32> for &i32[src]

type Output = <i32 as RemRounding>::Output

impl RemRounding<&'_ i32> for &i32[src]

type Output = <i32 as RemRounding>::Output

impl RemRounding<i64> for i64[src]

type Output = i64

impl RemRounding<&'_ i64> for i64[src]

type Output = <i64 as RemRounding>::Output

impl RemRounding<i64> for &i64[src]

type Output = <i64 as RemRounding>::Output

impl RemRounding<&'_ i64> for &i64[src]

type Output = <i64 as RemRounding>::Output

impl RemRounding<i128> for i128[src]

type Output = i128

impl RemRounding<&'_ i128> for i128[src]

type Output = <i128 as RemRounding>::Output

impl RemRounding<i128> for &i128[src]

type Output = <i128 as RemRounding>::Output

impl RemRounding<&'_ i128> for &i128[src]

type Output = <i128 as RemRounding>::Output

impl RemRounding<isize> for isize[src]

type Output = isize

impl RemRounding<&'_ isize> for isize[src]

type Output = <isize as RemRounding>::Output

impl RemRounding<isize> for &isize[src]

type Output = <isize as RemRounding>::Output

impl RemRounding<&'_ isize> for &isize[src]

type Output = <isize as RemRounding>::Output

impl RemRounding<f32> for f32[src]

type Output = f32

impl RemRounding<&'_ f32> for f32[src]

type Output = <f32 as RemRounding>::Output

impl RemRounding<f32> for &f32[src]

type Output = <f32 as RemRounding>::Output

impl RemRounding<&'_ f32> for &f32[src]

type Output = <f32 as RemRounding>::Output

impl RemRounding<f64> for f64[src]

type Output = f64

impl RemRounding<&'_ f64> for f64[src]

type Output = <f64 as RemRounding>::Output

impl RemRounding<f64> for &f64[src]

type Output = <f64 as RemRounding>::Output

impl RemRounding<&'_ f64> for &f64[src]

type Output = <f64 as RemRounding>::Output

impl RemRounding<Integer> for i8[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for i8[src]

type Output = RemRoundingFromI8Incomplete<'i>

impl RemRounding<Integer> for &i8[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &i8[src]

type Output = RemRoundingFromI8Incomplete<'i>

impl RemRounding<Integer> for i16[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for i16[src]

type Output = RemRoundingFromI16Incomplete<'i>

impl RemRounding<Integer> for &i16[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &i16[src]

type Output = RemRoundingFromI16Incomplete<'i>

impl RemRounding<Integer> for i32[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for i32[src]

type Output = RemRoundingFromI32Incomplete<'i>

impl RemRounding<Integer> for &i32[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &i32[src]

type Output = RemRoundingFromI32Incomplete<'i>

impl RemRounding<Integer> for i64[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for i64[src]

type Output = RemRoundingFromI64Incomplete<'i>

impl RemRounding<Integer> for &i64[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &i64[src]

type Output = RemRoundingFromI64Incomplete<'i>

impl RemRounding<Integer> for i128[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for i128[src]

type Output = RemRoundingFromI128Incomplete<'i>

impl RemRounding<Integer> for &i128[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &i128[src]

type Output = RemRoundingFromI128Incomplete<'i>

impl RemRounding<Integer> for u8[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for u8[src]

type Output = RemRoundingFromU8Incomplete<'i>

impl RemRounding<Integer> for &u8[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &u8[src]

type Output = RemRoundingFromU8Incomplete<'i>

impl RemRounding<Integer> for u16[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for u16[src]

type Output = RemRoundingFromU16Incomplete<'i>

impl RemRounding<Integer> for &u16[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &u16[src]

type Output = RemRoundingFromU16Incomplete<'i>

impl RemRounding<Integer> for u32[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for u32[src]

type Output = RemRoundingFromU32Incomplete<'i>

impl RemRounding<Integer> for &u32[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &u32[src]

type Output = RemRoundingFromU32Incomplete<'i>

impl RemRounding<Integer> for u64[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for u64[src]

type Output = RemRoundingFromU64Incomplete<'i>

impl RemRounding<Integer> for &u64[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &u64[src]

type Output = RemRoundingFromU64Incomplete<'i>

impl RemRounding<Integer> for u128[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for u128[src]

type Output = RemRoundingFromU128Incomplete<'i>

impl RemRounding<Integer> for &u128[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &u128[src]

type Output = RemRoundingFromU128Incomplete<'i>

Loading content...

Implementors

impl RemRounding<&'_ i8> for Integer[src]

type Output = Integer

impl RemRounding<&'_ i16> for Integer[src]

type Output = Integer

impl RemRounding<&'_ i32> for Integer[src]

type Output = Integer

impl RemRounding<&'_ i64> for Integer[src]

type Output = Integer

impl RemRounding<&'_ i128> for Integer[src]

type Output = Integer

impl RemRounding<&'_ u8> for Integer[src]

type Output = Integer

impl RemRounding<&'_ u16> for Integer[src]

type Output = Integer

impl RemRounding<&'_ u32> for Integer[src]

type Output = Integer

impl RemRounding<&'_ u64> for Integer[src]

type Output = Integer

impl RemRounding<&'_ u128> for Integer[src]

type Output = Integer

impl RemRounding<&'_ Integer> for Integer[src]

type Output = Integer

impl RemRounding<i8> for Integer[src]

type Output = Integer

impl RemRounding<i16> for Integer[src]

type Output = Integer

impl RemRounding<i32> for Integer[src]

type Output = Integer

impl RemRounding<i64> for Integer[src]

type Output = Integer

impl RemRounding<i128> for Integer[src]

type Output = Integer

impl RemRounding<u8> for Integer[src]

type Output = Integer

impl RemRounding<u16> for Integer[src]

type Output = Integer

impl RemRounding<u32> for Integer[src]

type Output = Integer

impl RemRounding<u64> for Integer[src]

type Output = Integer

impl RemRounding<u128> for Integer[src]

type Output = Integer

impl RemRounding<Integer> for &Integer[src]

type Output = Integer

impl RemRounding<Integer> for Integer[src]

type Output = Integer

impl<'i> RemRounding<&'i Integer> for &'i Integer[src]

type Output = RemRoundingIncomplete<'i>

impl<'i> RemRounding<i8> for &'i Integer[src]

type Output = RemRoundingI8Incomplete<'i>

impl<'i> RemRounding<i16> for &'i Integer[src]

type Output = RemRoundingI16Incomplete<'i>

impl<'i> RemRounding<i32> for &'i Integer[src]

type Output = RemRoundingI32Incomplete<'i>

impl<'i> RemRounding<i64> for &'i Integer[src]

type Output = RemRoundingI64Incomplete<'i>

impl<'i> RemRounding<i128> for &'i Integer[src]

type Output = RemRoundingI128Incomplete<'i>

impl<'i> RemRounding<u8> for &'i Integer[src]

type Output = RemRoundingU8Incomplete<'i>

impl<'i> RemRounding<u16> for &'i Integer[src]

type Output = RemRoundingU16Incomplete<'i>

impl<'i> RemRounding<u32> for &'i Integer[src]

type Output = RemRoundingU32Incomplete<'i>

impl<'i> RemRounding<u64> for &'i Integer[src]

type Output = RemRoundingU64Incomplete<'i>

impl<'i> RemRounding<u128> for &'i Integer[src]

type Output = RemRoundingU128Incomplete<'i>

impl<'t, 'i> RemRounding<&'t i8> for &'i Integer[src]

type Output = RemRoundingI8Incomplete<'i>

impl<'t, 'i> RemRounding<&'t i16> for &'i Integer[src]

type Output = RemRoundingI16Incomplete<'i>

impl<'t, 'i> RemRounding<&'t i32> for &'i Integer[src]

type Output = RemRoundingI32Incomplete<'i>

impl<'t, 'i> RemRounding<&'t i64> for &'i Integer[src]

type Output = RemRoundingI64Incomplete<'i>

impl<'t, 'i> RemRounding<&'t i128> for &'i Integer[src]

type Output = RemRoundingI128Incomplete<'i>

impl<'t, 'i> RemRounding<&'t u8> for &'i Integer[src]

type Output = RemRoundingU8Incomplete<'i>

impl<'t, 'i> RemRounding<&'t u16> for &'i Integer[src]

type Output = RemRoundingU16Incomplete<'i>

impl<'t, 'i> RemRounding<&'t u32> for &'i Integer[src]

type Output = RemRoundingU32Incomplete<'i>

impl<'t, 'i> RemRounding<&'t u64> for &'i Integer[src]

type Output = RemRoundingU64Incomplete<'i>

impl<'t, 'i> RemRounding<&'t u128> for &'i Integer[src]

type Output = RemRoundingU128Incomplete<'i>

Loading content...