pub trait Integer:
Sized
+ Num
+ PartialOrd
+ Ord
+ Eq {
Show 18 methods
// Required methods
fn div_floor(&self, other: &Self) -> Self;
fn mod_floor(&self, other: &Self) -> Self;
fn gcd(&self, other: &Self) -> Self;
fn lcm(&self, other: &Self) -> Self;
fn is_multiple_of(&self, other: &Self) -> bool;
fn is_even(&self) -> bool;
fn is_odd(&self) -> bool;
fn div_rem(&self, other: &Self) -> (Self, Self);
// Provided methods
fn div_ceil(&self, other: &Self) -> Self { ... }
fn gcd_lcm(&self, other: &Self) -> (Self, Self) { ... }
fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>
where Self: Clone { ... }
fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)
where Self: Clone + Signed { ... }
fn divides(&self, other: &Self) -> bool { ... }
fn div_mod_floor(&self, other: &Self) -> (Self, Self) { ... }
fn next_multiple_of(&self, other: &Self) -> Self
where Self: Clone { ... }
fn prev_multiple_of(&self, other: &Self) -> Self
where Self: Clone { ... }
fn dec(&mut self)
where Self: Clone { ... }
fn inc(&mut self)
where Self: Clone { ... }
}
Required Methods§
sourcefn div_floor(&self, other: &Self) -> Self
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);
sourcefn mod_floor(&self, other: &Self) -> Self
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);
sourcefn lcm(&self, other: &Self) -> Self
fn lcm(&self, other: &Self) -> Self
Lowest Common Multiple (LCM).
§Examples
assert_eq!(7.lcm(&3), 21);
assert_eq!(2.lcm(&4), 4);
assert_eq!(0.lcm(&0), 0);
sourcefn is_multiple_of(&self, other: &Self) -> bool
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);
sourcefn is_even(&self) -> bool
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);
sourcefn is_odd(&self) -> bool
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);
sourcefn div_rem(&self, other: &Self) -> (Self, Self)
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§
sourcefn div_ceil(&self, other: &Self) -> Self
fn div_ceil(&self, other: &Self) -> Self
Ceiled integer division.
§Examples
assert_eq!(( 8).div_ceil( &3), 3);
assert_eq!(( 8).div_ceil(&-3), -2);
assert_eq!((-8).div_ceil( &3), -2);
assert_eq!((-8).div_ceil(&-3), 3);
assert_eq!(( 1).div_ceil( &2), 1);
assert_eq!(( 1).div_ceil(&-2), 0);
assert_eq!((-1).div_ceil( &2), 0);
assert_eq!((-1).div_ceil(&-2), 1);
sourcefn gcd_lcm(&self, other: &Self) -> (Self, Self)
fn gcd_lcm(&self, other: &Self) -> (Self, Self)
Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) together.
Potentially more efficient than calling gcd
and lcm
individually for identical inputs.
§Examples
assert_eq!(10.gcd_lcm(&4), (2, 20));
assert_eq!(8.gcd_lcm(&9), (1, 72));
sourcefn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
Greatest common divisor and Bézout coefficients.
§Examples
fn check<A: Copy + Integer + NumAssign>(a: A, b: A) -> bool {
let ExtendedGcd { gcd, x, y, .. } = a.extended_gcd(&b);
gcd == x * a + y * b
}
assert!(check(10isize, 4isize));
assert!(check(8isize, 9isize));
sourcefn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)
fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)
Greatest common divisor, least common multiple, and Bézout coefficients.
sourcefn divides(&self, other: &Self) -> bool
👎Deprecated: Please use is_multiple_of instead
fn divides(&self, other: &Self) -> bool
Deprecated, use is_multiple_of
instead.
sourcefn div_mod_floor(&self, other: &Self) -> (Self, Self)
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));
sourcefn next_multiple_of(&self, other: &Self) -> Selfwhere
Self: Clone,
fn next_multiple_of(&self, other: &Self) -> Selfwhere
Self: Clone,
Rounds up to nearest multiple of argument.
§Notes
For signed types, a.next_multiple_of(b) = a.prev_multiple_of(b.neg())
.
§Examples
assert_eq!(( 16).next_multiple_of(& 8), 16);
assert_eq!(( 23).next_multiple_of(& 8), 24);
assert_eq!(( 16).next_multiple_of(&-8), 16);
assert_eq!(( 23).next_multiple_of(&-8), 16);
assert_eq!((-16).next_multiple_of(& 8), -16);
assert_eq!((-23).next_multiple_of(& 8), -16);
assert_eq!((-16).next_multiple_of(&-8), -16);
assert_eq!((-23).next_multiple_of(&-8), -24);
sourcefn prev_multiple_of(&self, other: &Self) -> Selfwhere
Self: Clone,
fn prev_multiple_of(&self, other: &Self) -> Selfwhere
Self: Clone,
Rounds down to nearest multiple of argument.
§Notes
For signed types, a.prev_multiple_of(b) = a.next_multiple_of(b.neg())
.
§Examples
assert_eq!(( 16).prev_multiple_of(& 8), 16);
assert_eq!(( 23).prev_multiple_of(& 8), 16);
assert_eq!(( 16).prev_multiple_of(&-8), 16);
assert_eq!(( 23).prev_multiple_of(&-8), 24);
assert_eq!((-16).prev_multiple_of(& 8), -16);
assert_eq!((-23).prev_multiple_of(& 8), -24);
assert_eq!((-16).prev_multiple_of(&-8), -16);
assert_eq!((-23).prev_multiple_of(&-8), -16);
Object Safety§
Implementations on Foreign Types§
source§impl Integer for i8
impl Integer for i8
source§fn div_mod_floor(&self, other: &i8) -> (i8, i8)
fn div_mod_floor(&self, other: &i8) -> (i8, i8)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &i8) -> i8
fn gcd(&self, other: &i8) -> i8
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &i8) -> i8
fn lcm(&self, other: &i8) -> i8
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &i8) -> (i8, i8)
fn gcd_lcm(&self, other: &i8) -> (i8, i8)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &i8) -> bool
fn is_multiple_of(&self, other: &i8) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &i8) -> (i8, i8)
fn div_rem(&self, other: &i8) -> (i8, i8)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &i8) -> i8
fn next_multiple_of(&self, other: &i8) -> i8
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &i8) -> i8
fn prev_multiple_of(&self, other: &i8) -> i8
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &i8) -> i8
fn extended_gcd_lcm(&self, other: &i8) -> (ExtendedGcd<i8>, i8)
source§impl Integer for i16
impl Integer for i16
source§fn div_mod_floor(&self, other: &i16) -> (i16, i16)
fn div_mod_floor(&self, other: &i16) -> (i16, i16)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &i16) -> i16
fn gcd(&self, other: &i16) -> i16
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &i16) -> i16
fn lcm(&self, other: &i16) -> i16
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &i16) -> (i16, i16)
fn gcd_lcm(&self, other: &i16) -> (i16, i16)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &i16) -> bool
fn is_multiple_of(&self, other: &i16) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &i16) -> (i16, i16)
fn div_rem(&self, other: &i16) -> (i16, i16)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &i16) -> i16
fn next_multiple_of(&self, other: &i16) -> i16
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &i16) -> i16
fn prev_multiple_of(&self, other: &i16) -> i16
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &i16) -> i16
fn extended_gcd_lcm(&self, other: &i16) -> (ExtendedGcd<i16>, i16)
source§impl Integer for i32
impl Integer for i32
source§fn div_mod_floor(&self, other: &i32) -> (i32, i32)
fn div_mod_floor(&self, other: &i32) -> (i32, i32)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &i32) -> i32
fn gcd(&self, other: &i32) -> i32
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &i32) -> i32
fn lcm(&self, other: &i32) -> i32
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &i32) -> (i32, i32)
fn gcd_lcm(&self, other: &i32) -> (i32, i32)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &i32) -> bool
fn is_multiple_of(&self, other: &i32) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &i32) -> (i32, i32)
fn div_rem(&self, other: &i32) -> (i32, i32)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &i32) -> i32
fn next_multiple_of(&self, other: &i32) -> i32
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &i32) -> i32
fn prev_multiple_of(&self, other: &i32) -> i32
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &i32) -> i32
fn extended_gcd_lcm(&self, other: &i32) -> (ExtendedGcd<i32>, i32)
source§impl Integer for i64
impl Integer for i64
source§fn div_mod_floor(&self, other: &i64) -> (i64, i64)
fn div_mod_floor(&self, other: &i64) -> (i64, i64)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &i64) -> i64
fn gcd(&self, other: &i64) -> i64
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &i64) -> i64
fn lcm(&self, other: &i64) -> i64
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &i64) -> (i64, i64)
fn gcd_lcm(&self, other: &i64) -> (i64, i64)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &i64) -> bool
fn is_multiple_of(&self, other: &i64) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &i64) -> (i64, i64)
fn div_rem(&self, other: &i64) -> (i64, i64)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &i64) -> i64
fn next_multiple_of(&self, other: &i64) -> i64
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &i64) -> i64
fn prev_multiple_of(&self, other: &i64) -> i64
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &i64) -> i64
fn extended_gcd_lcm(&self, other: &i64) -> (ExtendedGcd<i64>, i64)
source§impl Integer for i128
impl Integer for i128
source§fn div_mod_floor(&self, other: &i128) -> (i128, i128)
fn div_mod_floor(&self, other: &i128) -> (i128, i128)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &i128) -> i128
fn gcd(&self, other: &i128) -> i128
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &i128) -> i128
fn lcm(&self, other: &i128) -> i128
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &i128) -> (i128, i128)
fn gcd_lcm(&self, other: &i128) -> (i128, i128)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &i128) -> bool
fn is_multiple_of(&self, other: &i128) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &i128) -> (i128, i128)
fn div_rem(&self, other: &i128) -> (i128, i128)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &i128) -> i128
fn next_multiple_of(&self, other: &i128) -> i128
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &i128) -> i128
fn prev_multiple_of(&self, other: &i128) -> i128
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &i128) -> i128
fn extended_gcd_lcm(&self, other: &i128) -> (ExtendedGcd<i128>, i128)
source§impl Integer for isize
impl Integer for isize
source§fn div_mod_floor(&self, other: &isize) -> (isize, isize)
fn div_mod_floor(&self, other: &isize) -> (isize, isize)
Calculates div_floor
and mod_floor
simultaneously
source§fn gcd(&self, other: &isize) -> isize
fn gcd(&self, other: &isize) -> isize
Calculates the Greatest Common Divisor (GCD) of the number and
other
. The result is always non-negative.
source§fn lcm(&self, other: &isize) -> isize
fn lcm(&self, other: &isize) -> isize
Calculates the Lowest Common Multiple (LCM) of the number and
other
.
source§fn gcd_lcm(&self, other: &isize) -> (isize, isize)
fn gcd_lcm(&self, other: &isize) -> (isize, isize)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &isize) -> bool
fn is_multiple_of(&self, other: &isize) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &isize) -> (isize, isize)
fn div_rem(&self, other: &isize) -> (isize, isize)
Simultaneous truncated integer division and modulus.
source§fn next_multiple_of(&self, other: &isize) -> isize
fn next_multiple_of(&self, other: &isize) -> isize
Rounds up to nearest multiple of argument.
source§fn prev_multiple_of(&self, other: &isize) -> isize
fn prev_multiple_of(&self, other: &isize) -> isize
Rounds down to nearest multiple of argument.
fn div_ceil(&self, other: &isize) -> isize
fn extended_gcd_lcm(&self, other: &isize) -> (ExtendedGcd<isize>, isize)
source§impl Integer for u8
impl Integer for u8
source§fn div_floor(&self, other: &u8) -> u8
fn div_floor(&self, other: &u8) -> u8
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &u8) -> u8
fn mod_floor(&self, other: &u8) -> u8
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &u8) -> u8
fn gcd(&self, other: &u8) -> u8
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &u8) -> u8
fn lcm(&self, other: &u8) -> u8
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &u8) -> (u8, u8)
fn gcd_lcm(&self, other: &u8) -> (u8, u8)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &u8) -> bool
fn is_multiple_of(&self, other: &u8) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &u8) -> (u8, u8)
fn div_rem(&self, other: &u8) -> (u8, u8)
Simultaneous truncated integer division and modulus.
fn div_ceil(&self, other: &u8) -> u8
fn extended_gcd_lcm(&self, other: &u8) -> (ExtendedGcd<u8>, u8)
source§impl Integer for u16
impl Integer for u16
source§fn div_floor(&self, other: &u16) -> u16
fn div_floor(&self, other: &u16) -> u16
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &u16) -> u16
fn mod_floor(&self, other: &u16) -> u16
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &u16) -> u16
fn gcd(&self, other: &u16) -> u16
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &u16) -> u16
fn lcm(&self, other: &u16) -> u16
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &u16) -> (u16, u16)
fn gcd_lcm(&self, other: &u16) -> (u16, u16)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &u16) -> bool
fn is_multiple_of(&self, other: &u16) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &u16) -> (u16, u16)
fn div_rem(&self, other: &u16) -> (u16, u16)
Simultaneous truncated integer division and modulus.
fn div_ceil(&self, other: &u16) -> u16
fn extended_gcd_lcm(&self, other: &u16) -> (ExtendedGcd<u16>, u16)
source§impl Integer for u32
impl Integer for u32
source§fn div_floor(&self, other: &u32) -> u32
fn div_floor(&self, other: &u32) -> u32
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &u32) -> u32
fn mod_floor(&self, other: &u32) -> u32
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &u32) -> u32
fn gcd(&self, other: &u32) -> u32
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &u32) -> u32
fn lcm(&self, other: &u32) -> u32
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &u32) -> (u32, u32)
fn gcd_lcm(&self, other: &u32) -> (u32, u32)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &u32) -> bool
fn is_multiple_of(&self, other: &u32) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &u32) -> (u32, u32)
fn div_rem(&self, other: &u32) -> (u32, u32)
Simultaneous truncated integer division and modulus.
fn div_ceil(&self, other: &u32) -> u32
fn extended_gcd_lcm(&self, other: &u32) -> (ExtendedGcd<u32>, u32)
source§impl Integer for u64
impl Integer for u64
source§fn div_floor(&self, other: &u64) -> u64
fn div_floor(&self, other: &u64) -> u64
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &u64) -> u64
fn mod_floor(&self, other: &u64) -> u64
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &u64) -> u64
fn gcd(&self, other: &u64) -> u64
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &u64) -> u64
fn lcm(&self, other: &u64) -> u64
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &u64) -> (u64, u64)
fn gcd_lcm(&self, other: &u64) -> (u64, u64)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &u64) -> bool
fn is_multiple_of(&self, other: &u64) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &u64) -> (u64, u64)
fn div_rem(&self, other: &u64) -> (u64, u64)
Simultaneous truncated integer division and modulus.
fn div_ceil(&self, other: &u64) -> u64
fn extended_gcd_lcm(&self, other: &u64) -> (ExtendedGcd<u64>, u64)
source§impl Integer for u128
impl Integer for u128
source§fn div_floor(&self, other: &u128) -> u128
fn div_floor(&self, other: &u128) -> u128
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &u128) -> u128
fn mod_floor(&self, other: &u128) -> u128
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &u128) -> u128
fn gcd(&self, other: &u128) -> u128
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &u128) -> u128
fn lcm(&self, other: &u128) -> u128
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &u128) -> (u128, u128)
fn gcd_lcm(&self, other: &u128) -> (u128, u128)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &u128) -> bool
fn is_multiple_of(&self, other: &u128) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &u128) -> (u128, u128)
fn div_rem(&self, other: &u128) -> (u128, u128)
Simultaneous truncated integer division and modulus.
fn div_ceil(&self, other: &u128) -> u128
fn extended_gcd_lcm(&self, other: &u128) -> (ExtendedGcd<u128>, u128)
source§impl Integer for usize
impl Integer for usize
source§fn div_floor(&self, other: &usize) -> usize
fn div_floor(&self, other: &usize) -> usize
Unsigned integer division. Returns the same result as div
(/
).
source§fn mod_floor(&self, other: &usize) -> usize
fn mod_floor(&self, other: &usize) -> usize
Unsigned integer modulo operation. Returns the same result as rem
(%
).
source§fn gcd(&self, other: &usize) -> usize
fn gcd(&self, other: &usize) -> usize
Calculates the Greatest Common Divisor (GCD) of the number and other
source§fn lcm(&self, other: &usize) -> usize
fn lcm(&self, other: &usize) -> usize
Calculates the Lowest Common Multiple (LCM) of the number and other
.
source§fn gcd_lcm(&self, other: &usize) -> (usize, usize)
fn gcd_lcm(&self, other: &usize) -> (usize, usize)
Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and other
.
source§fn is_multiple_of(&self, other: &usize) -> bool
fn is_multiple_of(&self, other: &usize) -> bool
Returns true
if the number is a multiple of other
.
source§fn div_rem(&self, other: &usize) -> (usize, usize)
fn div_rem(&self, other: &usize) -> (usize, usize)
Simultaneous truncated integer division and modulus.