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
The resulting type from the remainder operation.
Required Methods
fn rem_trunc(self, rhs: Rhs) -> Self::Output
Finds the remainder when the quotient is rounded towards zero.
fn rem_ceil(self, rhs: Rhs) -> Self::Output
Finds the remainder when the quotient is rounded up.
fn rem_floor(self, rhs: Rhs) -> Self::Output
Finds the remainder when the quotient is rounded down.
fn rem_euc(self, rhs: Rhs) -> Self::Output
Finds the positive remainder from Euclidean division.
Implementations on Foreign Types
impl RemRounding for i8
[src]
impl RemRounding for i8
impl<'a> RemRounding<&'a i8> for i8
[src]
impl<'a> RemRounding<&'a i8> for i8
impl<'a> RemRounding<i8> for &'a i8
[src]
impl<'a> RemRounding<i8> for &'a i8
impl<'a, 'b> RemRounding<&'a i8> for &'b i8
[src]
impl<'a, 'b> RemRounding<&'a i8> for &'b i8
impl RemRounding for i16
[src]
impl RemRounding for i16
impl<'a> RemRounding<&'a i16> for i16
[src]
impl<'a> RemRounding<&'a i16> for i16
impl<'a> RemRounding<i16> for &'a i16
[src]
impl<'a> RemRounding<i16> for &'a i16
impl<'a, 'b> RemRounding<&'a i16> for &'b i16
[src]
impl<'a, 'b> RemRounding<&'a i16> for &'b i16
impl RemRounding for i32
[src]
impl RemRounding for i32
impl<'a> RemRounding<&'a i32> for i32
[src]
impl<'a> RemRounding<&'a i32> for i32
impl<'a> RemRounding<i32> for &'a i32
[src]
impl<'a> RemRounding<i32> for &'a i32
impl<'a, 'b> RemRounding<&'a i32> for &'b i32
[src]
impl<'a, 'b> RemRounding<&'a i32> for &'b i32
impl RemRounding for i64
[src]
impl RemRounding for i64
impl<'a> RemRounding<&'a i64> for i64
[src]
impl<'a> RemRounding<&'a i64> for i64
impl<'a> RemRounding<i64> for &'a i64
[src]
impl<'a> RemRounding<i64> for &'a i64
impl<'a, 'b> RemRounding<&'a i64> for &'b i64
[src]
impl<'a, 'b> RemRounding<&'a i64> for &'b i64
impl RemRounding for i128
[src]
impl RemRounding for i128
impl<'a> RemRounding<&'a i128> for i128
[src]
impl<'a> RemRounding<&'a i128> for i128
impl<'a> RemRounding<i128> for &'a i128
[src]
impl<'a> RemRounding<i128> for &'a i128
impl<'a, 'b> RemRounding<&'a i128> for &'b i128
[src]
impl<'a, 'b> RemRounding<&'a i128> for &'b i128
impl RemRounding for isize
[src]
impl RemRounding for isize
impl<'a> RemRounding<&'a isize> for isize
[src]
impl<'a> RemRounding<&'a isize> for isize
impl<'a> RemRounding<isize> for &'a isize
[src]
impl<'a> RemRounding<isize> for &'a isize
impl<'a, 'b> RemRounding<&'a isize> for &'b isize
[src]
impl<'a, 'b> RemRounding<&'a isize> for &'b isize
impl RemRounding for f32
[src]
impl RemRounding for f32
impl<'a> RemRounding<&'a f32> for f32
[src]
impl<'a> RemRounding<&'a f32> for f32
impl<'a> RemRounding<f32> for &'a f32
[src]
impl<'a> RemRounding<f32> for &'a f32
impl<'a, 'b> RemRounding<&'a f32> for &'b f32
[src]
impl<'a, 'b> RemRounding<&'a f32> for &'b f32
impl RemRounding for f64
[src]
impl RemRounding for f64
impl<'a> RemRounding<&'a f64> for f64
[src]
impl<'a> RemRounding<&'a f64> for f64
impl<'a> RemRounding<f64> for &'a f64
[src]
impl<'a> RemRounding<f64> for &'a f64
impl<'a, 'b> RemRounding<&'a f64> for &'b f64
[src]
impl<'a, 'b> RemRounding<&'a f64> for &'b f64
impl RemRounding<Integer> for i32
[src]
impl RemRounding<Integer> for i32
impl<'i> RemRounding<&'i Integer> for i32
[src]
impl<'i> RemRounding<&'i Integer> for i32
type Output = RemRoundingFromI32Incomplete<'i>
fn rem_trunc(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
[src]
fn rem_trunc(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
fn rem_ceil(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
[src]
fn rem_ceil(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
fn rem_floor(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
[src]
fn rem_floor(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
fn rem_euc(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
[src]
fn rem_euc(self, rhs: &Integer) -> RemRoundingFromI32Incomplete
impl<'t> RemRounding<Integer> for &'t i32
[src]
impl<'t> RemRounding<Integer> for &'t i32
impl<'i, 't> RemRounding<&'i Integer> for &'t i32
[src]
impl<'i, 't> RemRounding<&'i Integer> for &'t i32
type Output = RemRoundingFromI32Incomplete<'i>
fn rem_trunc(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
[src]
fn rem_trunc(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
fn rem_ceil(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
[src]
fn rem_ceil(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
fn rem_floor(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
[src]
fn rem_floor(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
fn rem_euc(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
[src]
fn rem_euc(self, rhs: &'i Integer) -> RemRoundingFromI32Incomplete<'i>
impl RemRounding<Integer> for u32
[src]
impl RemRounding<Integer> for u32
impl<'i> RemRounding<&'i Integer> for u32
[src]
impl<'i> RemRounding<&'i Integer> for u32
type Output = RemRoundingFromU32Incomplete<'i>
fn rem_trunc(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
[src]
fn rem_trunc(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
fn rem_ceil(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
[src]
fn rem_ceil(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
fn rem_floor(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
[src]
fn rem_floor(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
fn rem_euc(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
[src]
fn rem_euc(self, rhs: &Integer) -> RemRoundingFromU32Incomplete
impl<'t> RemRounding<Integer> for &'t u32
[src]
impl<'t> RemRounding<Integer> for &'t u32
impl<'i, 't> RemRounding<&'i Integer> for &'t u32
[src]
impl<'i, 't> RemRounding<&'i Integer> for &'t u32
type Output = RemRoundingFromU32Incomplete<'i>
fn rem_trunc(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
[src]
fn rem_trunc(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
fn rem_ceil(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
[src]
fn rem_ceil(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
fn rem_floor(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
[src]
fn rem_floor(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
fn rem_euc(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
[src]
fn rem_euc(self, rhs: &'i Integer) -> RemRoundingFromU32Incomplete<'i>
Implementors
impl RemRounding for Integer type Output = Integer;
impl<'i> RemRounding<&'i Integer> for Integer type Output = Integer;
impl<'i> RemRounding<Integer> for &'i Integer type Output = Integer;
impl<'i> RemRounding for &'i Integer type Output = RemRoundingIncomplete<'i>;
impl RemRounding<i32> for Integer type Output = Integer;
impl<'t> RemRounding<&'t i32> for Integer type Output = Integer;
impl<'i> RemRounding<i32> for &'i Integer type Output = RemRoundingI32Incomplete<'i>;
impl<'t, 'i> RemRounding<&'t i32> for &'i Integer type Output = RemRoundingI32Incomplete<'i>;
impl RemRounding<u32> for Integer type Output = Integer;
impl<'t> RemRounding<&'t u32> for Integer type Output = Integer;
impl<'i> RemRounding<u32> for &'i Integer type Output = RemRoundingU32Incomplete<'i>;
impl<'t, 'i> RemRounding<&'t u32> for &'i Integer type Output = RemRoundingU32Incomplete<'i>;