Skip to main content

Integer

Trait Integer 

Source
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ยง

Source

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);
Source

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);
Source

fn gcd(&self, other: &Self) -> Self

Greatest Common Divisor (GCD).

The result should always be non-negative.

ยงExamples
assert_eq!(6.gcd(&8), 2);
assert_eq!(7.gcd(&3), 1);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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ยง

Source

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);
Source

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));
Source

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));
Source

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)
where Self: Clone + Signed,

Greatest common divisor, least common multiple, and Bรฉzout coefficients.

Source

fn divides(&self, other: &Self) -> bool

๐Ÿ‘ŽDeprecated:

Please use is_multiple_of instead

Deprecated, use is_multiple_of instead.

Source

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));
Source

fn next_multiple_of(&self, other: &Self) -> Self
where 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);
Source

fn prev_multiple_of(&self, other: &Self) -> Self
where 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);
Source

fn dec(&mut self)
where Self: Clone,

Decrements self by one.

ยงExamples
let mut x: i32 = 43;
x.dec();
assert_eq!(x, 42);
Source

fn inc(&mut self)
where Self: Clone,

Increments self by one.

ยงExamples
let mut x: i32 = 41;
x.inc();
assert_eq!(x, 42);

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Typesยง

Sourceยง

impl Integer for i8

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for i16

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for i32

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for i64

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for i128

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for isize

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Floored integer division

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo

Sourceยง

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Calculates div_floor and mod_floor simultaneously

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn next_multiple_of(&self, other: &Self) -> Self

Rounds up to nearest multiple of argument.

Sourceยง

fn prev_multiple_of(&self, other: &Self) -> Self

Rounds down to nearest multiple of argument.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for u8

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for u16

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for u32

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for u64

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for u128

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Sourceยง

impl Integer for usize

Sourceยง

fn div_floor(&self, other: &Self) -> Self

Unsigned integer division. Returns the same result as div (/).

Sourceยง

fn mod_floor(&self, other: &Self) -> Self

Unsigned integer modulo operation. Returns the same result as rem (%).

Sourceยง

fn gcd(&self, other: &Self) -> Self

Calculates the Greatest Common Divisor (GCD) of the number and other

Sourceยง

fn lcm(&self, other: &Self) -> Self

Calculates the Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.

Sourceยง

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if the number is a multiple of other.

Sourceยง

fn is_even(&self) -> bool

Returns true if the number is divisible by 2.

Sourceยง

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2.

Sourceยง

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus.

Sourceยง

fn div_ceil(&self, other: &Self) -> Self

Sourceยง

fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)

Implementorsยง