Trait rug::ops::RemRoundingAssign [−][src]
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)
[src]
Finds the remainder when the quotient is rounded towards zero.
fn rem_ceil_assign(&mut self, rhs: Rhs)
[src]
Finds the remainder when the quotient is rounded up.
fn rem_floor_assign(&mut self, rhs: Rhs)
[src]
Finds the remainder when the quotient is rounded down.
fn rem_euc_assign(&mut self, rhs: Rhs)
[src]
Finds the positive remainder from Euclidean division.