[][src]Trait rug::ops::RemRoundingAssign

pub trait RemRoundingAssign<Rhs = Self> {
    fn rem_trunc_assign(&mut self, rhs: Rhs);
fn rem_ceil_assign(&mut self, rhs: Rhs);
fn rem_floor_assign(&mut self, rhs: Rhs);
fn rem_euc_assign(&mut self, rhs: Rhs); }

Compound assignment and rounding variants of the remainder operation.

Examples

use rug::ops::RemRoundingAssign;
struct I(i32);
impl RemRoundingAssign<i32> for I {
    fn rem_trunc_assign(&mut self, rhs: i32) {
        self.0 %= rhs;
    }
    fn rem_ceil_assign(&mut self, rhs: i32) {
        let r = self.0 % rhs;
        let change = if rhs > 0 { r > 0 } else { r < 0 };
        self.0 = if change { r - rhs } else { r };
    }
    fn rem_floor_assign(&mut self, rhs: i32) {
        let r = self.0 % rhs;
        let change = if rhs > 0 { r < 0 } else { r > 0 };
        self.0 = if change { r + rhs } else { r };
    }
    fn rem_euc_assign(&mut self, rhs: i32) {
        let r = self.0 % rhs;
        self.0 = if r < 0 {
            if rhs < 0 {
                r - rhs
            } else {
                r + rhs
            }
        } else {
            r
        };
    }
}
let mut rem_floor = I(-10);
rem_floor.rem_floor_assign(3);
assert_eq!(rem_floor.0, 2);

Required methods

fn rem_trunc_assign(&mut self, rhs: Rhs)

Finds the remainder when the quotient is rounded towards zero.

fn rem_ceil_assign(&mut self, rhs: Rhs)

Finds the remainder when the quotient is rounded up.

fn rem_floor_assign(&mut self, rhs: Rhs)

Finds the remainder when the quotient is rounded down.

fn rem_euc_assign(&mut self, rhs: Rhs)

Finds the positive remainder from Euclidean division.

Loading content...

Implementations on Foreign Types

impl RemRoundingAssign<i8> for i8[src]

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

impl RemRoundingAssign<i16> for i16[src]

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

impl RemRoundingAssign<i32> for i32[src]

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

impl RemRoundingAssign<i64> for i64[src]

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

impl RemRoundingAssign<i128> for i128[src]

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

impl RemRoundingAssign<isize> for isize[src]

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

impl RemRoundingAssign<f32> for f32[src]

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

impl RemRoundingAssign<f64> for f64[src]

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

Loading content...

Implementors

impl RemRoundingAssign<i32> for Integer[src]

impl RemRoundingAssign<u32> for Integer[src]

impl RemRoundingAssign<Integer> for Integer[src]

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

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

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

Loading content...