Trait ndarray_rand::rand_distr::num_traits::CheckedRem[][src]

pub trait CheckedRem: Rem<Self, Output = Self> {
    pub fn checked_rem(&self, v: &Self) -> Option<Self>;
}

Performs an integral remainder that returns None instead of panicking on division by zero and instead of wrapping around on underflow and overflow.

Required methods

pub fn checked_rem(&self, v: &Self) -> Option<Self>[src]

Finds the remainder of dividing two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.

Examples

use num_traits::CheckedRem;
use std::i32::MIN;

assert_eq!(CheckedRem::checked_rem(&10, &7), Some(3));
assert_eq!(CheckedRem::checked_rem(&10, &-7), Some(3));
assert_eq!(CheckedRem::checked_rem(&-10, &7), Some(-3));
assert_eq!(CheckedRem::checked_rem(&-10, &-7), Some(-3));

assert_eq!(CheckedRem::checked_rem(&10, &0), None);

assert_eq!(CheckedRem::checked_rem(&MIN, &1), Some(0));
assert_eq!(CheckedRem::checked_rem(&MIN, &-1), None);
Loading content...

Implementations on Foreign Types

impl CheckedRem for u8[src]

impl CheckedRem for u16[src]

impl CheckedRem for i32[src]

impl CheckedRem for usize[src]

impl CheckedRem for u32[src]

impl CheckedRem for u128[src]

impl CheckedRem for i16[src]

impl CheckedRem for isize[src]

impl CheckedRem for i128[src]

impl CheckedRem for u64[src]

impl CheckedRem for i64[src]

impl CheckedRem for i8[src]

Loading content...

Implementors

Loading content...