[][src]Trait rug::ops::RemRoundingFrom

pub trait RemRoundingFrom<Lhs = Self> {
    fn rem_trunc_from(&mut self, lhs: Lhs);
fn rem_ceil_from(&mut self, lhs: Lhs);
fn rem_floor_from(&mut self, lhs: Lhs);
fn rem_euc_from(&mut self, lhs: Lhs); }

Compound assignment to the rhs operand and rounding variants of the remainder operation.

Examples

use rug::ops::RemRoundingFrom;
struct I(i32);
impl RemRoundingFrom<i32> for I {
    fn rem_trunc_from(&mut self, lhs: i32) {
        self.0 = lhs % self.0;
    }
    fn rem_ceil_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        let change = if self.0 > 0 { r > 0 } else { r < 0 };
        self.0 = if change { r - self.0 } else { r };
    }
    fn rem_floor_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        let change = if self.0 > 0 { r < 0 } else { r > 0 };
        self.0 = if change { r + self.0 } else { r };
    }
    fn rem_euc_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        self.0 = if r < 0 {
            if self.0 < 0 {
                r - self.0
            } else {
                r + self.0
            }
        } else {
            r
        };
    }
}
let mut rem_ceil = I(3);
rem_ceil.rem_ceil_from(10);
assert_eq!(rem_ceil.0, -2);

Required methods

fn rem_trunc_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded towards zero.

fn rem_ceil_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded up.

fn rem_floor_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded down.

fn rem_euc_from(&mut self, lhs: Lhs)

Finds the positive remainder from Euclidean division.

Loading content...

Implementations on Foreign Types

impl RemRoundingFrom<i8> for i8[src]

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

impl RemRoundingFrom<i16> for i16[src]

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

impl RemRoundingFrom<i32> for i32[src]

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

impl RemRoundingFrom<i64> for i64[src]

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

impl RemRoundingFrom<i128> for i128[src]

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

impl RemRoundingFrom<isize> for isize[src]

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

impl RemRoundingFrom<f32> for f32[src]

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

impl RemRoundingFrom<f64> for f64[src]

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

Loading content...

Implementors

impl RemRoundingFrom<i32> for Integer[src]

impl RemRoundingFrom<u32> for Integer[src]

impl RemRoundingFrom<Integer> for Integer[src]

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

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

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

Loading content...