Trait rug::ops::DivRoundingAssign[][src]

pub trait DivRoundingAssign<Rhs = Self> {
    fn div_trunc_assign(&mut self, rhs: Rhs);
fn div_ceil_assign(&mut self, rhs: Rhs);
fn div_floor_assign(&mut self, rhs: Rhs);
fn div_euc_assign(&mut self, rhs: Rhs); }

Compound assignment and rounding variants of division.

Examples

use rug::ops::DivRoundingAssign;
struct I(i32);
impl DivRoundingAssign<i32> for I {
    fn div_trunc_assign(&mut self, rhs: i32) {
        self.0 /= rhs;
    }
    fn div_ceil_assign(&mut self, rhs: i32) {
        let (q, r) = (self.0 / rhs, self.0 % rhs);
        let change = if rhs > 0 { r > 0 } else { r < 0 };
        self.0 = if change { q + 1 } else { q };
    }
    fn div_floor_assign(&mut self, rhs: i32) {
        let (q, r) = (self.0 / rhs, self.0 % rhs);
        let change = if rhs > 0 { r < 0 } else { r > 0 };
        self.0 = if change { q - 1 } else { q };
    }
    fn div_euc_assign(&mut self, rhs: i32) {
        let (q, r) = (self.0 / rhs, self.0 % rhs);
        self.0 = if r < 0 {
            if rhs < 0 {
                q + 1
            } else {
                q - 1
            }
        } else {
            q
        };
    }
}
let mut div_floor = I(-10);
div_floor.div_floor_assign(3);
assert_eq!(div_floor.0, -4);

Required methods

fn div_trunc_assign(&mut self, rhs: Rhs)[src]

Performs division, rounding the quotient towards zero.

fn div_ceil_assign(&mut self, rhs: Rhs)[src]

Performs division, rounding the quotient up.

fn div_floor_assign(&mut self, rhs: Rhs)[src]

Performs division, rounding the quotient down.

fn div_euc_assign(&mut self, rhs: Rhs)[src]

Performs Euclidean division, rounding the quotient so that the remainder cannot be negative.

Loading content...

Implementations on Foreign Types

impl DivRoundingAssign<i8> for i8[src]

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

impl DivRoundingAssign<i16> for i16[src]

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

impl DivRoundingAssign<i32> for i32[src]

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

impl DivRoundingAssign<i64> for i64[src]

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

impl DivRoundingAssign<i128> for i128[src]

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

impl DivRoundingAssign<isize> for isize[src]

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

impl DivRoundingAssign<u8> for u8[src]

impl DivRoundingAssign<&'_ u8> for u8[src]

impl DivRoundingAssign<u16> for u16[src]

impl DivRoundingAssign<&'_ u16> for u16[src]

impl DivRoundingAssign<u32> for u32[src]

impl DivRoundingAssign<&'_ u32> for u32[src]

impl DivRoundingAssign<u64> for u64[src]

impl DivRoundingAssign<&'_ u64> for u64[src]

impl DivRoundingAssign<u128> for u128[src]

impl DivRoundingAssign<&'_ u128> for u128[src]

impl DivRoundingAssign<usize> for usize[src]

impl DivRoundingAssign<&'_ usize> for usize[src]

impl DivRoundingAssign<f32> for f32[src]

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

impl DivRoundingAssign<f64> for f64[src]

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

Loading content...

Implementors

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

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

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

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

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

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

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

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

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

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

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

impl DivRoundingAssign<i8> for Integer[src]

impl DivRoundingAssign<i16> for Integer[src]

impl DivRoundingAssign<i32> for Integer[src]

impl DivRoundingAssign<i64> for Integer[src]

impl DivRoundingAssign<i128> for Integer[src]

impl DivRoundingAssign<u8> for Integer[src]

impl DivRoundingAssign<u16> for Integer[src]

impl DivRoundingAssign<u32> for Integer[src]

impl DivRoundingAssign<u64> for Integer[src]

impl DivRoundingAssign<u128> for Integer[src]

impl DivRoundingAssign<Integer> for Integer[src]

Loading content...