[−][src]Trait num_integer::Integer
Required Methods
fn div_floor(&self, other: &Self) -> Self
Floored integer division.
Examples
assert!(( 8).div_floor(& 3) == 2); assert!(( 8).div_floor(&-3) == -3); assert!((-8).div_floor(& 3) == -3); assert!((-8).div_floor(&-3) == 2); assert!(( 1).div_floor(& 2) == 0); assert!(( 1).div_floor(&-2) == -1); assert!((-1).div_floor(& 2) == -1); assert!((-1).div_floor(&-2) == 0);
fn mod_floor(&self, other: &Self) -> Self
Floored integer modulo, satisfying:
assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n)
Examples
assert!(( 8).mod_floor(& 3) == 2); assert!(( 8).mod_floor(&-3) == -1); assert!((-8).mod_floor(& 3) == 1); assert!((-8).mod_floor(&-3) == -2); assert!(( 1).mod_floor(& 2) == 1); assert!(( 1).mod_floor(&-2) == -1); assert!((-1).mod_floor(& 2) == 1); assert!((-1).mod_floor(&-2) == -1);
fn gcd(&self, other: &Self) -> Self
fn lcm(&self, other: &Self) -> Self
fn divides(&self, other: &Self) -> bool
Deprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool
Returns true if self is a multiple of other.
Examples
assert_eq!(9.is_multiple_of(&3), true); assert_eq!(3.is_multiple_of(&9), false);
fn is_even(&self) -> bool
Returns true if the number is even.
Examples
assert_eq!(3.is_even(), false); assert_eq!(4.is_even(), true);
fn is_odd(&self) -> bool
Returns true if the number is odd.
Examples
assert_eq!(3.is_odd(), true); assert_eq!(4.is_odd(), false);
fn div_rem(&self, other: &Self) -> (Self, Self)
Simultaneous truncated integer division and modulus.
Returns (quotient, remainder).
Examples
assert_eq!(( 8).div_rem( &3), ( 2, 2)); assert_eq!(( 8).div_rem(&-3), (-2, 2)); assert_eq!((-8).div_rem( &3), (-2, -2)); assert_eq!((-8).div_rem(&-3), ( 2, -2)); assert_eq!(( 1).div_rem( &2), ( 0, 1)); assert_eq!(( 1).div_rem(&-2), ( 0, 1)); assert_eq!((-1).div_rem( &2), ( 0, -1)); assert_eq!((-1).div_rem(&-2), ( 0, -1));
Provided Methods
fn div_mod_floor(&self, other: &Self) -> (Self, Self)
Simultaneous floored integer division and modulus.
Returns (quotient, remainder).
Examples
assert_eq!(( 8).div_mod_floor( &3), ( 2, 2)); assert_eq!(( 8).div_mod_floor(&-3), (-3, -1)); assert_eq!((-8).div_mod_floor( &3), (-3, 1)); assert_eq!((-8).div_mod_floor(&-3), ( 2, -2)); assert_eq!(( 1).div_mod_floor( &2), ( 0, 1)); assert_eq!(( 1).div_mod_floor(&-2), (-1, -1)); assert_eq!((-1).div_mod_floor( &2), (-1, 1)); assert_eq!((-1).div_mod_floor(&-2), ( 0, -1));
Implementations on Foreign Types
impl Integer for i8[src]
impl Integer for i8fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for i16[src]
impl Integer for i16fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for i32[src]
impl Integer for i32fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for i64[src]
impl Integer for i64fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for isize[src]
impl Integer for isizefn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for i128[src]
impl Integer for i128fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfFloored integer division
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfFloored integer modulo
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)Calculates div_floor and mod_floor simultaneously
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and
other. The result is always positive.
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and
other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
impl Integer for u8[src]
impl Integer for u8fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)impl Integer for u16[src]
impl Integer for u16fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)impl Integer for u32[src]
impl Integer for u32fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)impl Integer for u64[src]
impl Integer for u64fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)impl Integer for usize[src]
impl Integer for usizefn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)impl Integer for u128[src]
impl Integer for u128fn div_floor(&self, other: &Self) -> Self[src]
fn div_floor(&self, other: &Self) -> SelfUnsigned integer division. Returns the same result as div (/).
fn mod_floor(&self, other: &Self) -> Self[src]
fn mod_floor(&self, other: &Self) -> SelfUnsigned integer modulo operation. Returns the same result as rem (%).
fn gcd(&self, other: &Self) -> Self[src]
fn gcd(&self, other: &Self) -> SelfCalculates the Greatest Common Divisor (GCD) of the number and other
fn lcm(&self, other: &Self) -> Self[src]
fn lcm(&self, other: &Self) -> SelfCalculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &Self) -> bool[src]
fn divides(&self, other: &Self) -> boolDeprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &Self) -> bool[src]
fn is_multiple_of(&self, other: &Self) -> boolReturns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
fn is_even(&self) -> boolReturns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
fn is_odd(&self) -> boolReturns true if the number is not divisible by 2.
fn div_rem(&self, other: &Self) -> (Self, Self)[src]
fn div_rem(&self, other: &Self) -> (Self, Self)Simultaneous truncated integer division and modulus.
fn div_mod_floor(&self, other: &Self) -> (Self, Self)[src]
fn div_mod_floor(&self, other: &Self) -> (Self, Self)