devela::num

Struct Int

Source
#[repr(transparent)]
pub struct Int<T>(pub T);
Expand description

Provides comprehensive integer operations on T, most of them const.

It’s implemented for:

  • all the integer primitives: i8, …, i128, u8, …, u128.

Specific implementations can vary between signed and signed numeric types, but documentation is the same for all bit sizes:

See also the related trait NumInt.

Tuple Fields§

§0: T

Implementations§

Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn digits(self) -> Int<i8>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_i8).digits()];
assert_eq![Int(1), Int(-1_i8).digits()];
assert_eq![Int(3), Int(127_i8).digits()];
assert_eq![Int(3), Int(-128_i8).digits()];
Source

pub const fn digits_sign(self) -> Int<i8>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_i8).digits_sign()];
assert_eq![Int(2), Int(-1_i8).digits_sign()];
assert_eq![Int(3), Int(127_i8).digits_sign()];
assert_eq![Int(4), Int(-128_i8).digits_sign()];
Source

pub const fn digits_base(self, base: i8) -> Int<i8>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i8).digits_base(2)];
assert_eq![Int(2), Int(127_i8).digits_base(16)];
assert_eq![Int(2), Int(-128_i8).digits_base(16)];
assert_eq![Int(2), Int(-128_i8).digits_base(-16)];
assert_eq![Int(0), Int(100_i8).digits_base(0)];
assert_eq![Int(1), Int(0_i8).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: i8) -> Int<i8>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i8).digits_base_sign(2)];
assert_eq![Int(2), Int(127_i8).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i8).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i8).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_i8).digits_base_sign(0)];
assert_eq![Int(1), Int(0_i8).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<i8>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_i8).digital_root()];
assert_eq![Int(1), Int(-127_i8).digital_root()];
assert_eq![Int(9), Int(126_i8).digital_root()];
Source

pub const fn digital_root_base(self, base: i8) -> Int<i8>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_i8).digital_root_base(10)];
assert_eq![Int(1), Int(127_i8).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_i8).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_i8).digital_root_base(10)];
assert_eq![Int(3), Int(-33_i8).digital_root_base(16)];
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn digits(self) -> Int<i16>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_i16).digits()];
assert_eq![Int(1), Int(-1_i16).digits()];
assert_eq![Int(3), Int(127_i16).digits()];
assert_eq![Int(3), Int(-128_i16).digits()];
Source

pub const fn digits_sign(self) -> Int<i16>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_i16).digits_sign()];
assert_eq![Int(2), Int(-1_i16).digits_sign()];
assert_eq![Int(3), Int(127_i16).digits_sign()];
assert_eq![Int(4), Int(-128_i16).digits_sign()];
Source

pub const fn digits_base(self, base: i16) -> Int<i16>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i16).digits_base(2)];
assert_eq![Int(2), Int(127_i16).digits_base(16)];
assert_eq![Int(2), Int(-128_i16).digits_base(16)];
assert_eq![Int(2), Int(-128_i16).digits_base(-16)];
assert_eq![Int(0), Int(100_i16).digits_base(0)];
assert_eq![Int(1), Int(0_i16).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: i16) -> Int<i16>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i16).digits_base_sign(2)];
assert_eq![Int(2), Int(127_i16).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i16).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i16).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_i16).digits_base_sign(0)];
assert_eq![Int(1), Int(0_i16).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<i16>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_i16).digital_root()];
assert_eq![Int(1), Int(-127_i16).digital_root()];
assert_eq![Int(9), Int(126_i16).digital_root()];
Source

pub const fn digital_root_base(self, base: i16) -> Int<i16>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_i16).digital_root_base(10)];
assert_eq![Int(1), Int(127_i16).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_i16).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_i16).digital_root_base(10)];
assert_eq![Int(3), Int(-33_i16).digital_root_base(16)];
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn digits(self) -> Int<i32>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_i32).digits()];
assert_eq![Int(1), Int(-1_i32).digits()];
assert_eq![Int(3), Int(127_i32).digits()];
assert_eq![Int(3), Int(-128_i32).digits()];
Source

pub const fn digits_sign(self) -> Int<i32>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_i32).digits_sign()];
assert_eq![Int(2), Int(-1_i32).digits_sign()];
assert_eq![Int(3), Int(127_i32).digits_sign()];
assert_eq![Int(4), Int(-128_i32).digits_sign()];
Source

pub const fn digits_base(self, base: i32) -> Int<i32>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i32).digits_base(2)];
assert_eq![Int(2), Int(127_i32).digits_base(16)];
assert_eq![Int(2), Int(-128_i32).digits_base(16)];
assert_eq![Int(2), Int(-128_i32).digits_base(-16)];
assert_eq![Int(0), Int(100_i32).digits_base(0)];
assert_eq![Int(1), Int(0_i32).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: i32) -> Int<i32>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i32).digits_base_sign(2)];
assert_eq![Int(2), Int(127_i32).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i32).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i32).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_i32).digits_base_sign(0)];
assert_eq![Int(1), Int(0_i32).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<i32>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_i32).digital_root()];
assert_eq![Int(1), Int(-127_i32).digital_root()];
assert_eq![Int(9), Int(126_i32).digital_root()];
Source

pub const fn digital_root_base(self, base: i32) -> Int<i32>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_i32).digital_root_base(10)];
assert_eq![Int(1), Int(127_i32).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_i32).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_i32).digital_root_base(10)];
assert_eq![Int(3), Int(-33_i32).digital_root_base(16)];
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn digits(self) -> Int<i64>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_i64).digits()];
assert_eq![Int(1), Int(-1_i64).digits()];
assert_eq![Int(3), Int(127_i64).digits()];
assert_eq![Int(3), Int(-128_i64).digits()];
Source

pub const fn digits_sign(self) -> Int<i64>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_i64).digits_sign()];
assert_eq![Int(2), Int(-1_i64).digits_sign()];
assert_eq![Int(3), Int(127_i64).digits_sign()];
assert_eq![Int(4), Int(-128_i64).digits_sign()];
Source

pub const fn digits_base(self, base: i64) -> Int<i64>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i64).digits_base(2)];
assert_eq![Int(2), Int(127_i64).digits_base(16)];
assert_eq![Int(2), Int(-128_i64).digits_base(16)];
assert_eq![Int(2), Int(-128_i64).digits_base(-16)];
assert_eq![Int(0), Int(100_i64).digits_base(0)];
assert_eq![Int(1), Int(0_i64).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: i64) -> Int<i64>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i64).digits_base_sign(2)];
assert_eq![Int(2), Int(127_i64).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i64).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i64).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_i64).digits_base_sign(0)];
assert_eq![Int(1), Int(0_i64).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<i64>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_i64).digital_root()];
assert_eq![Int(1), Int(-127_i64).digital_root()];
assert_eq![Int(9), Int(126_i64).digital_root()];
Source

pub const fn digital_root_base(self, base: i64) -> Int<i64>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_i64).digital_root_base(10)];
assert_eq![Int(1), Int(127_i64).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_i64).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_i64).digital_root_base(10)];
assert_eq![Int(3), Int(-33_i64).digital_root_base(16)];
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn digits(self) -> Int<i128>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_i128).digits()];
assert_eq![Int(1), Int(-1_i128).digits()];
assert_eq![Int(3), Int(127_i128).digits()];
assert_eq![Int(3), Int(-128_i128).digits()];
Source

pub const fn digits_sign(self) -> Int<i128>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_i128).digits_sign()];
assert_eq![Int(2), Int(-1_i128).digits_sign()];
assert_eq![Int(3), Int(127_i128).digits_sign()];
assert_eq![Int(4), Int(-128_i128).digits_sign()];
Source

pub const fn digits_base(self, base: i128) -> Int<i128>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i128).digits_base(2)];
assert_eq![Int(2), Int(127_i128).digits_base(16)];
assert_eq![Int(2), Int(-128_i128).digits_base(16)];
assert_eq![Int(2), Int(-128_i128).digits_base(-16)];
assert_eq![Int(0), Int(100_i128).digits_base(0)];
assert_eq![Int(1), Int(0_i128).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: i128) -> Int<i128>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_i128).digits_base_sign(2)];
assert_eq![Int(2), Int(127_i128).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i128).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_i128).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_i128).digits_base_sign(0)];
assert_eq![Int(1), Int(0_i128).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<i128>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_i128).digital_root()];
assert_eq![Int(1), Int(-127_i128).digital_root()];
assert_eq![Int(9), Int(126_i128).digital_root()];
Source

pub const fn digital_root_base(self, base: i128) -> Int<i128>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_i128).digital_root_base(10)];
assert_eq![Int(1), Int(127_i128).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_i128).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_i128).digital_root_base(10)];
assert_eq![Int(3), Int(-33_i128).digital_root_base(16)];
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn digits(self) -> Int<isize>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_isize).digits()];
assert_eq![Int(1), Int(-1_isize).digits()];
assert_eq![Int(3), Int(127_isize).digits()];
assert_eq![Int(3), Int(-128_isize).digits()];
Source

pub const fn digits_sign(self) -> Int<isize>

Returns the number of digits in base 10, including the negative sign.

§Examples
assert_eq![Int(1), Int(0_isize).digits_sign()];
assert_eq![Int(2), Int(-1_isize).digits_sign()];
assert_eq![Int(3), Int(127_isize).digits_sign()];
assert_eq![Int(4), Int(-128_isize).digits_sign()];
Source

pub const fn digits_base(self, base: isize) -> Int<isize>

Returns the number of digits in the given absolute base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_isize).digits_base(2)];
assert_eq![Int(2), Int(127_isize).digits_base(16)];
assert_eq![Int(2), Int(-128_isize).digits_base(16)];
assert_eq![Int(2), Int(-128_isize).digits_base(-16)];
assert_eq![Int(0), Int(100_isize).digits_base(0)];
assert_eq![Int(1), Int(0_isize).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: isize) -> Int<isize>

Returns the number of digits in the given absolute base, including the negative sign.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_isize).digits_base_sign(2)];
assert_eq![Int(2), Int(127_isize).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_isize).digits_base_sign(16)];
assert_eq![Int(3), Int(-128_isize).digits_base_sign(-16)];
assert_eq![Int(0), Int(100_isize).digits_base_sign(0)];
assert_eq![Int(1), Int(0_isize).digits_base_sign(100)];
Source

pub const fn digital_root(self) -> Int<isize>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_isize).digital_root()];
assert_eq![Int(1), Int(-127_isize).digital_root()];
assert_eq![Int(9), Int(126_isize).digital_root()];
Source

pub const fn digital_root_base(self, base: isize) -> Int<isize>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_isize).digital_root_base(10)];
assert_eq![Int(1), Int(127_isize).digital_root_base(-10)];
assert_eq![Int(1), Int(-127_isize).digital_root_base(-10)];
assert_eq![Int(9), Int(-126_isize).digital_root_base(10)];
assert_eq![Int(3), Int(-33_isize).digital_root_base(16)];
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn digits(self) -> Int<u8>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_u8).digits()];
assert_eq![Int(3), Int(127_u8).digits()];
Source

pub const fn digits_sign(self) -> Int<u8>

An alias of digits.

Source

pub const fn digits_base(self, base: u8) -> Int<u8>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_u8).digits_base(2)];
assert_eq![Int(2), Int(127_u8).digits_base(16)];
assert_eq![Int(0), Int(100_u8).digits_base(0)];
assert_eq![Int(1), Int(0_u8).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: u8) -> Int<u8>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<u8>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_u8).digital_root()];
assert_eq![Int(9), Int(126_u8).digital_root()];
Source

pub const fn digital_root_base(self, base: u8) -> Int<u8>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_u8).digital_root_base(10)];
assert_eq![Int(3), Int(33_u8).digital_root_base(16)];
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn digits(self) -> Int<u16>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_u16).digits()];
assert_eq![Int(3), Int(127_u16).digits()];
Source

pub const fn digits_sign(self) -> Int<u16>

An alias of digits.

Source

pub const fn digits_base(self, base: u16) -> Int<u16>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_u16).digits_base(2)];
assert_eq![Int(2), Int(127_u16).digits_base(16)];
assert_eq![Int(0), Int(100_u16).digits_base(0)];
assert_eq![Int(1), Int(0_u16).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: u16) -> Int<u16>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<u16>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_u16).digital_root()];
assert_eq![Int(9), Int(126_u16).digital_root()];
Source

pub const fn digital_root_base(self, base: u16) -> Int<u16>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_u16).digital_root_base(10)];
assert_eq![Int(3), Int(33_u16).digital_root_base(16)];
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn digits(self) -> Int<u32>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_u32).digits()];
assert_eq![Int(3), Int(127_u32).digits()];
Source

pub const fn digits_sign(self) -> Int<u32>

An alias of digits.

Source

pub const fn digits_base(self, base: u32) -> Int<u32>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_u32).digits_base(2)];
assert_eq![Int(2), Int(127_u32).digits_base(16)];
assert_eq![Int(0), Int(100_u32).digits_base(0)];
assert_eq![Int(1), Int(0_u32).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: u32) -> Int<u32>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<u32>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_u32).digital_root()];
assert_eq![Int(9), Int(126_u32).digital_root()];
Source

pub const fn digital_root_base(self, base: u32) -> Int<u32>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_u32).digital_root_base(10)];
assert_eq![Int(3), Int(33_u32).digital_root_base(16)];
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn digits(self) -> Int<u64>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_u64).digits()];
assert_eq![Int(3), Int(127_u64).digits()];
Source

pub const fn digits_sign(self) -> Int<u64>

An alias of digits.

Source

pub const fn digits_base(self, base: u64) -> Int<u64>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_u64).digits_base(2)];
assert_eq![Int(2), Int(127_u64).digits_base(16)];
assert_eq![Int(0), Int(100_u64).digits_base(0)];
assert_eq![Int(1), Int(0_u64).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: u64) -> Int<u64>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<u64>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_u64).digital_root()];
assert_eq![Int(9), Int(126_u64).digital_root()];
Source

pub const fn digital_root_base(self, base: u64) -> Int<u64>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_u64).digital_root_base(10)];
assert_eq![Int(3), Int(33_u64).digital_root_base(16)];
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn digits(self) -> Int<u128>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_u128).digits()];
assert_eq![Int(3), Int(127_u128).digits()];
Source

pub const fn digits_sign(self) -> Int<u128>

An alias of digits.

Source

pub const fn digits_base(self, base: u128) -> Int<u128>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_u128).digits_base(2)];
assert_eq![Int(2), Int(127_u128).digits_base(16)];
assert_eq![Int(0), Int(100_u128).digits_base(0)];
assert_eq![Int(1), Int(0_u128).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: u128) -> Int<u128>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<u128>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_u128).digital_root()];
assert_eq![Int(9), Int(126_u128).digital_root()];
Source

pub const fn digital_root_base(self, base: u128) -> Int<u128>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_u128).digital_root_base(10)];
assert_eq![Int(3), Int(33_u128).digital_root_base(16)];
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn digits(self) -> Int<usize>

Returns the number of digits in base 10.

§Examples
assert_eq![Int(1), Int(0_usize).digits()];
assert_eq![Int(3), Int(127_usize).digits()];
Source

pub const fn digits_sign(self) -> Int<usize>

An alias of digits.

Source

pub const fn digits_base(self, base: usize) -> Int<usize>

Returns the number of digits in the given base.

If the base is 0, it returns 0.

§Examples
assert_eq![Int(2), Int(3_usize).digits_base(2)];
assert_eq![Int(2), Int(127_usize).digits_base(16)];
assert_eq![Int(0), Int(100_usize).digits_base(0)];
assert_eq![Int(1), Int(0_usize).digits_base(100)];
Source

pub const fn digits_base_sign(self, base: usize) -> Int<usize>

An alias of digits_base.

Source

pub const fn digital_root(self) -> Int<usize>

Returns the digital root in base 10.

§Examples
assert_eq![Int(1), Int(127_usize).digital_root()];
assert_eq![Int(9), Int(126_usize).digital_root()];
Source

pub const fn digital_root_base(self, base: usize) -> Int<usize>

Returns the digital root in in the given absolute base.

§Examples
assert_eq![Int(1), Int(127_usize).digital_root_base(10)];
assert_eq![Int(3), Int(33_usize).digital_root_base(16)];
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn factorial(self) -> Result<Int<i8>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_i8).factorial()];
assert_eq![Ok(Int(6)), Int(3_i8).factorial()];
assert_eq![Ok(Int(1)), Int(0_i8).factorial()];
assert![Int(-3_i8).factorial().is_err()];
assert![Int(i8::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<i8>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_i8).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_i8).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_i8).subfactorial()];
assert![Int(-3_i8).subfactorial().is_err()];
assert![Int(127_i8).subfactorial().is_err()];
Source

pub const fn combine(self, r: i8) -> Result<Int<i8>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_i8).combine(3)];
assert_eq![Ok(Int(3)), Int(3_i8).combine(2)];
assert_eq![Ok(Int(3)), Int(3_i8).combine(1)];
assert![Int(-3_i8).combine(3).is_err()];
assert![Int(3_i8).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: i8) -> Result<Int<i8>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_i8).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_i8).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i8).combine_rep(1)];
assert![Int(-3_i8).combine_rep(3).is_err()];
assert![Int(3_i8).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: i8) -> Result<Int<i8>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_i8).permute(3)];
assert_eq![Ok(Int(6)), Int(3_i8).permute(2)];
assert_eq![Ok(Int(3)), Int(3_i8).permute(1)];
assert![Int(-3_i8).permute(3).is_err()];
assert![Int(3_i8).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: i8) -> Result<Int<i8>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_i8).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_i8).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i8).permute_rep(1)];
assert![Int(-3_i8).permute_rep(3).is_err()];
assert![Int(3_i8).permute_rep(-2).is_err()];
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn factorial(self) -> Result<Int<i16>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_i16).factorial()];
assert_eq![Ok(Int(6)), Int(3_i16).factorial()];
assert_eq![Ok(Int(1)), Int(0_i16).factorial()];
assert![Int(-3_i16).factorial().is_err()];
assert![Int(i16::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<i16>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_i16).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_i16).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_i16).subfactorial()];
assert![Int(-3_i16).subfactorial().is_err()];
assert![Int(127_i16).subfactorial().is_err()];
Source

pub const fn combine(self, r: i16) -> Result<Int<i16>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_i16).combine(3)];
assert_eq![Ok(Int(3)), Int(3_i16).combine(2)];
assert_eq![Ok(Int(3)), Int(3_i16).combine(1)];
assert![Int(-3_i16).combine(3).is_err()];
assert![Int(3_i16).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: i16) -> Result<Int<i16>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_i16).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_i16).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i16).combine_rep(1)];
assert![Int(-3_i16).combine_rep(3).is_err()];
assert![Int(3_i16).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: i16) -> Result<Int<i16>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_i16).permute(3)];
assert_eq![Ok(Int(6)), Int(3_i16).permute(2)];
assert_eq![Ok(Int(3)), Int(3_i16).permute(1)];
assert![Int(-3_i16).permute(3).is_err()];
assert![Int(3_i16).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: i16) -> Result<Int<i16>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_i16).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_i16).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i16).permute_rep(1)];
assert![Int(-3_i16).permute_rep(3).is_err()];
assert![Int(3_i16).permute_rep(-2).is_err()];
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn factorial(self) -> Result<Int<i32>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_i32).factorial()];
assert_eq![Ok(Int(6)), Int(3_i32).factorial()];
assert_eq![Ok(Int(1)), Int(0_i32).factorial()];
assert![Int(-3_i32).factorial().is_err()];
assert![Int(i32::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<i32>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_i32).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_i32).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_i32).subfactorial()];
assert![Int(-3_i32).subfactorial().is_err()];
assert![Int(127_i32).subfactorial().is_err()];
Source

pub const fn combine(self, r: i32) -> Result<Int<i32>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_i32).combine(3)];
assert_eq![Ok(Int(3)), Int(3_i32).combine(2)];
assert_eq![Ok(Int(3)), Int(3_i32).combine(1)];
assert![Int(-3_i32).combine(3).is_err()];
assert![Int(3_i32).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: i32) -> Result<Int<i32>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_i32).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_i32).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i32).combine_rep(1)];
assert![Int(-3_i32).combine_rep(3).is_err()];
assert![Int(3_i32).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: i32) -> Result<Int<i32>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_i32).permute(3)];
assert_eq![Ok(Int(6)), Int(3_i32).permute(2)];
assert_eq![Ok(Int(3)), Int(3_i32).permute(1)];
assert![Int(-3_i32).permute(3).is_err()];
assert![Int(3_i32).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: i32) -> Result<Int<i32>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_i32).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_i32).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i32).permute_rep(1)];
assert![Int(-3_i32).permute_rep(3).is_err()];
assert![Int(3_i32).permute_rep(-2).is_err()];
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn factorial(self) -> Result<Int<i64>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_i64).factorial()];
assert_eq![Ok(Int(6)), Int(3_i64).factorial()];
assert_eq![Ok(Int(1)), Int(0_i64).factorial()];
assert![Int(-3_i64).factorial().is_err()];
assert![Int(i64::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<i64>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_i64).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_i64).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_i64).subfactorial()];
assert![Int(-3_i64).subfactorial().is_err()];
assert![Int(127_i64).subfactorial().is_err()];
Source

pub const fn combine(self, r: i64) -> Result<Int<i64>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_i64).combine(3)];
assert_eq![Ok(Int(3)), Int(3_i64).combine(2)];
assert_eq![Ok(Int(3)), Int(3_i64).combine(1)];
assert![Int(-3_i64).combine(3).is_err()];
assert![Int(3_i64).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: i64) -> Result<Int<i64>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_i64).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_i64).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i64).combine_rep(1)];
assert![Int(-3_i64).combine_rep(3).is_err()];
assert![Int(3_i64).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: i64) -> Result<Int<i64>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_i64).permute(3)];
assert_eq![Ok(Int(6)), Int(3_i64).permute(2)];
assert_eq![Ok(Int(3)), Int(3_i64).permute(1)];
assert![Int(-3_i64).permute(3).is_err()];
assert![Int(3_i64).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: i64) -> Result<Int<i64>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_i64).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_i64).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i64).permute_rep(1)];
assert![Int(-3_i64).permute_rep(3).is_err()];
assert![Int(3_i64).permute_rep(-2).is_err()];
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn factorial(self) -> Result<Int<i128>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_i128).factorial()];
assert_eq![Ok(Int(6)), Int(3_i128).factorial()];
assert_eq![Ok(Int(1)), Int(0_i128).factorial()];
assert![Int(-3_i128).factorial().is_err()];
assert![Int(i128::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<i128>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_i128).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_i128).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_i128).subfactorial()];
assert![Int(-3_i128).subfactorial().is_err()];
assert![Int(127_i128).subfactorial().is_err()];
Source

pub const fn combine(self, r: i128) -> Result<Int<i128>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_i128).combine(3)];
assert_eq![Ok(Int(3)), Int(3_i128).combine(2)];
assert_eq![Ok(Int(3)), Int(3_i128).combine(1)];
assert![Int(-3_i128).combine(3).is_err()];
assert![Int(3_i128).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: i128) -> Result<Int<i128>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_i128).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_i128).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i128).combine_rep(1)];
assert![Int(-3_i128).combine_rep(3).is_err()];
assert![Int(3_i128).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: i128) -> Result<Int<i128>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_i128).permute(3)];
assert_eq![Ok(Int(6)), Int(3_i128).permute(2)];
assert_eq![Ok(Int(3)), Int(3_i128).permute(1)];
assert![Int(-3_i128).permute(3).is_err()];
assert![Int(3_i128).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: i128) -> Result<Int<i128>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_i128).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_i128).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_i128).permute_rep(1)];
assert![Int(-3_i128).permute_rep(3).is_err()];
assert![Int(3_i128).permute_rep(-2).is_err()];
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn factorial(self) -> Result<Int<isize>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for i8, 7 for i16, 12 for i32, 20 for i64 and 33 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_isize).factorial()];
assert_eq![Ok(Int(6)), Int(3_isize).factorial()];
assert_eq![Ok(Int(1)), Int(0_isize).factorial()];
assert![Int(-3_isize).factorial().is_err()];
assert![Int(isize::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<isize>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for i8, 8 for i16, 12 for i32, 20 for i64 and 35 for i128.

§Errors

Returns NonNegativeRequired if $n<0$, and Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. i32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_isize).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_isize).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_isize).subfactorial()];
assert![Int(-3_isize).subfactorial().is_err()];
assert![Int(127_isize).subfactorial().is_err()];
Source

pub const fn combine(self, r: isize) -> Result<Int<isize>>

Combinations of n items taken r at a time, ordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $r > n$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_isize).combine(3)];
assert_eq![Ok(Int(3)), Int(3_isize).combine(2)];
assert_eq![Ok(Int(3)), Int(3_isize).combine(1)];
assert![Int(-3_isize).combine(3).is_err()];
assert![Int(3_isize).combine(-2).is_err()];
Source

pub const fn combine_rep(self, r: isize) -> Result<Int<isize>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_isize).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_isize).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_isize).combine_rep(1)];
assert![Int(-3_isize).combine_rep(3).is_err()];
assert![Int(3_isize).combine_rep(-2).is_err()];
Source

pub const fn permute(self, r: isize) -> Result<Int<isize>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, MismatchedSizes if $|r| > |n|$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_isize).permute(3)];
assert_eq![Ok(Int(6)), Int(3_isize).permute(2)];
assert_eq![Ok(Int(3)), Int(3_isize).permute(1)];
assert![Int(-3_isize).permute(3).is_err()];
assert![Int(3_isize).permute(-2).is_err()];
Source

pub const fn permute_rep(self, r: isize) -> Result<Int<isize>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns NonNegativeRequired if $n<0 \lor r<0$, and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_isize).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_isize).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_isize).permute_rep(1)];
assert![Int(-3_isize).permute_rep(3).is_err()];
assert![Int(3_isize).permute_rep(-2).is_err()];
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn factorial(self) -> Result<Int<u8>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_u8).factorial()];
assert_eq![Ok(Int(6)), Int(3_u8).factorial()];
assert_eq![Ok(Int(1)), Int(0_u8).factorial()];
assert![Int(u8::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<u8>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_u8).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_u8).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_u8).subfactorial()];
assert![Int(255_u8).subfactorial().is_err()];
Source

pub const fn combine(self, r: u8) -> Result<Int<u8>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_u8).combine(3)];
assert_eq![Ok(Int(3)), Int(3_u8).combine(2)];
assert_eq![Ok(Int(3)), Int(3_u8).combine(1)];
assert![Int(u8::MAX).combine(u8::MAX).is_err()];
Source

pub const fn combine_rep(self, r: u8) -> Result<Int<u8>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_u8).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_u8).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u8).combine_rep(1)];
assert![Int(u8::MAX).combine_rep(u8::MAX).is_err()];
Source

pub const fn permute(self, r: u8) -> Result<Int<u8>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_u8).permute(3)];
assert_eq![Ok(Int(6)), Int(3_u8).permute(2)];
assert_eq![Ok(Int(3)), Int(3_u8).permute(1)];
assert![Int(3_u8).permute(4_u8).is_err()];
assert![Int(u8::MAX).permute(u8::MAX).is_err()];
Source

pub const fn permute_rep(self, r: u8) -> Result<Int<u8>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_u8).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_u8).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u8).permute_rep(1)];
assert![Int(u8::MAX).permute_rep(u8::MAX).is_err()];
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn factorial(self) -> Result<Int<u16>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_u16).factorial()];
assert_eq![Ok(Int(6)), Int(3_u16).factorial()];
assert_eq![Ok(Int(1)), Int(0_u16).factorial()];
assert![Int(u16::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<u16>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_u16).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_u16).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_u16).subfactorial()];
assert![Int(255_u16).subfactorial().is_err()];
Source

pub const fn combine(self, r: u16) -> Result<Int<u16>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_u16).combine(3)];
assert_eq![Ok(Int(3)), Int(3_u16).combine(2)];
assert_eq![Ok(Int(3)), Int(3_u16).combine(1)];
assert![Int(u16::MAX).combine(u16::MAX).is_err()];
Source

pub const fn combine_rep(self, r: u16) -> Result<Int<u16>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_u16).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_u16).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u16).combine_rep(1)];
assert![Int(u16::MAX).combine_rep(u16::MAX).is_err()];
Source

pub const fn permute(self, r: u16) -> Result<Int<u16>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_u16).permute(3)];
assert_eq![Ok(Int(6)), Int(3_u16).permute(2)];
assert_eq![Ok(Int(3)), Int(3_u16).permute(1)];
assert![Int(3_u16).permute(4_u16).is_err()];
assert![Int(u16::MAX).permute(u16::MAX).is_err()];
Source

pub const fn permute_rep(self, r: u16) -> Result<Int<u16>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_u16).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_u16).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u16).permute_rep(1)];
assert![Int(u16::MAX).permute_rep(u16::MAX).is_err()];
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn factorial(self) -> Result<Int<u32>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_u32).factorial()];
assert_eq![Ok(Int(6)), Int(3_u32).factorial()];
assert_eq![Ok(Int(1)), Int(0_u32).factorial()];
assert![Int(u32::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<u32>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_u32).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_u32).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_u32).subfactorial()];
assert![Int(255_u32).subfactorial().is_err()];
Source

pub const fn combine(self, r: u32) -> Result<Int<u32>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_u32).combine(3)];
assert_eq![Ok(Int(3)), Int(3_u32).combine(2)];
assert_eq![Ok(Int(3)), Int(3_u32).combine(1)];
assert![Int(u32::MAX).combine(u32::MAX).is_err()];
Source

pub const fn combine_rep(self, r: u32) -> Result<Int<u32>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_u32).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_u32).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u32).combine_rep(1)];
assert![Int(u32::MAX).combine_rep(u32::MAX).is_err()];
Source

pub const fn permute(self, r: u32) -> Result<Int<u32>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_u32).permute(3)];
assert_eq![Ok(Int(6)), Int(3_u32).permute(2)];
assert_eq![Ok(Int(3)), Int(3_u32).permute(1)];
assert![Int(3_u32).permute(4_u32).is_err()];
assert![Int(u32::MAX).permute(u32::MAX).is_err()];
Source

pub const fn permute_rep(self, r: u32) -> Result<Int<u32>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_u32).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_u32).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u32).permute_rep(1)];
assert![Int(u32::MAX).permute_rep(u32::MAX).is_err()];
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn factorial(self) -> Result<Int<u64>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_u64).factorial()];
assert_eq![Ok(Int(6)), Int(3_u64).factorial()];
assert_eq![Ok(Int(1)), Int(0_u64).factorial()];
assert![Int(u64::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<u64>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_u64).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_u64).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_u64).subfactorial()];
assert![Int(255_u64).subfactorial().is_err()];
Source

pub const fn combine(self, r: u64) -> Result<Int<u64>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_u64).combine(3)];
assert_eq![Ok(Int(3)), Int(3_u64).combine(2)];
assert_eq![Ok(Int(3)), Int(3_u64).combine(1)];
assert![Int(u64::MAX).combine(u64::MAX).is_err()];
Source

pub const fn combine_rep(self, r: u64) -> Result<Int<u64>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_u64).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_u64).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u64).combine_rep(1)];
assert![Int(u64::MAX).combine_rep(u64::MAX).is_err()];
Source

pub const fn permute(self, r: u64) -> Result<Int<u64>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_u64).permute(3)];
assert_eq![Ok(Int(6)), Int(3_u64).permute(2)];
assert_eq![Ok(Int(3)), Int(3_u64).permute(1)];
assert![Int(3_u64).permute(4_u64).is_err()];
assert![Int(u64::MAX).permute(u64::MAX).is_err()];
Source

pub const fn permute_rep(self, r: u64) -> Result<Int<u64>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_u64).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_u64).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u64).permute_rep(1)];
assert![Int(u64::MAX).permute_rep(u64::MAX).is_err()];
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn factorial(self) -> Result<Int<u128>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_u128).factorial()];
assert_eq![Ok(Int(6)), Int(3_u128).factorial()];
assert_eq![Ok(Int(1)), Int(0_u128).factorial()];
assert![Int(u128::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<u128>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_u128).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_u128).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_u128).subfactorial()];
assert![Int(255_u128).subfactorial().is_err()];
Source

pub const fn combine(self, r: u128) -> Result<Int<u128>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_u128).combine(3)];
assert_eq![Ok(Int(3)), Int(3_u128).combine(2)];
assert_eq![Ok(Int(3)), Int(3_u128).combine(1)];
assert![Int(u128::MAX).combine(u128::MAX).is_err()];
Source

pub const fn combine_rep(self, r: u128) -> Result<Int<u128>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_u128).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_u128).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u128).combine_rep(1)];
assert![Int(u128::MAX).combine_rep(u128::MAX).is_err()];
Source

pub const fn permute(self, r: u128) -> Result<Int<u128>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_u128).permute(3)];
assert_eq![Ok(Int(6)), Int(3_u128).permute(2)];
assert_eq![Ok(Int(3)), Int(3_u128).permute(1)];
assert![Int(3_u128).permute(4_u128).is_err()];
assert![Int(u128::MAX).permute(u128::MAX).is_err()];
Source

pub const fn permute_rep(self, r: u128) -> Result<Int<u128>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_u128).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_u128).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_u128).permute_rep(1)];
assert![Int(u128::MAX).permute_rep(u128::MAX).is_err()];
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn factorial(self) -> Result<Int<usize>>

Returns the factorial.

Permutations of n items, ordered, where $n = r$.

§Formula

$$ n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (n-1) \cdot n $$

These are the maximum numbers whose factorials can fit within standard signed integer types:

5 for u8, 8 for u16, 12 for u32, 20 for u64 and 34 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(120)), Int(5_usize).factorial()];
assert_eq![Ok(Int(6)), Int(3_usize).factorial()];
assert_eq![Ok(Int(1)), Int(0_usize).factorial()];
assert![Int(usize::MAX).factorial().is_err()];
Source

pub const fn subfactorial(self) -> Result<Int<usize>>

Returns the subfactorial, or the number of derangements.

Permutations of n items which no element appears in its original position.

§Formulation
§Algorithm

The current implementation uses the recursive definition: $$

  • Base cases: ( !0 = 1 ) and ( !1 = 0 ).
  • For ( n > 1 ), compute ( !(n - 1) ) and ( !(n - 2) ) recursively, and combine them: $$ \large !n = (n - 1) \cdot (!(n - 1) + !(n - 2)). $$
§Closed-Form Formulas

Other equivalent formulas for ( !n ) include:

  1. Summation Formula: $$ \large !n = n! \times \sum_{k=0}^{n} \frac{(-1)^k}{k!} $$
  2. Approximation Formula: \large !n = \left\lfloor \frac{n!}{e} + \frac{1}{2} \right\rfloor = \left\lfloor n! \times \left(\frac{1}{e}\right) + \frac{1}{2} \right\rfloor $$

These are the maximum numbers whose subfactorials can fit within standard signed integer types:

5 for u8, 8 for u16, 13 for u32, 20 for u64 and 35 for u128.

§Errors

Returns Overflow if the result can’t fit the type.

§Panics

For very large values (e.g. u32:MAX) the stack can overflow.

§Examples
assert_eq![Ok(Int(44)), Int(5_usize).subfactorial()];
assert_eq![Ok(Int(9)), Int(4_usize).subfactorial()];
assert_eq![Ok(Int(1)), Int(0_usize).subfactorial()];
assert![Int(255_usize).subfactorial().is_err()];
Source

pub const fn combine(self, r: usize) -> Result<Int<usize>>

Combinations of n items taken r at a time, unordered.

§Formula

$$ \large C(n,r) = {n \choose r} = \frac{n!}{(n−r)!r!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(1)), Int(3_usize).combine(3)];
assert_eq![Ok(Int(3)), Int(3_usize).combine(2)];
assert_eq![Ok(Int(3)), Int(3_usize).combine(1)];
assert![Int(usize::MAX).combine(usize::MAX).is_err()];
Source

pub const fn combine_rep(self, r: usize) -> Result<Int<usize>>

Combinations of n items taken r at a time with repetitions, unordered.

Also known as multichoose.

§Formula

$$ \large C(n+r-1,r) = {n+k-1 \choose r} = \frac{(n+r-1)!}{(n−1)!r!} $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(10)), Int(3_usize).combine_rep(3)];
assert_eq![Ok(Int(6)), Int(3_usize).combine_rep(2)];
assert_eq![Ok(Int(3)), Int(3_usize).combine_rep(1)];
assert![Int(usize::MAX).combine_rep(usize::MAX).is_err()];
Source

pub const fn permute(self, r: usize) -> Result<Int<usize>>

Permutations of n items taken r at a time, ordered.

When $n=r$ or $n=r-1$ the result is the same as calculating the factorial $n!$.

§Formula

$$ \large P(n,r) = \frac{n!}{(n−r)!} $$

§Errors

Returns MismatchedSizes if $r > n$ and Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(6)), Int(3_usize).permute(3)];
assert_eq![Ok(Int(6)), Int(3_usize).permute(2)];
assert_eq![Ok(Int(3)), Int(3_usize).permute(1)];
assert![Int(3_usize).permute(4_usize).is_err()];
assert![Int(usize::MAX).permute(usize::MAX).is_err()];
Source

pub const fn permute_rep(self, r: usize) -> Result<Int<usize>>

Available on crate feature cast only.

Permutations of n items taken r at a time with repetitions, ordered.

§Formula

$$ \large P_\text{rep}(n,r) = n_r $$

§Errors

Returns Overflow if the result cant’t fit the type.

§Examples
assert_eq![Ok(Int(27)), Int(3_usize).permute_rep(3)];
assert_eq![Ok(Int(9)), Int(3_usize).permute_rep(2)];
assert_eq![Ok(Int(3)), Int(3_usize).permute_rep(1)];
assert![Int(usize::MAX).permute_rep(usize::MAX).is_err()];
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn abs(self) -> Int<i8>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_i8).is_even()];
assert![Int(-2_i8).is_even()];
assert![!Int(3_i8).is_even()];
assert![Int(0_i8).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_i8).is_odd()];
assert![Int(-3_i8).is_odd()];
assert![!Int(2_i8).is_odd()];
assert![!Int(0_i8).is_odd()];
Source

pub const fn gcd(self, b: i8) -> Int<i8>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_i8).gcd(36)];
assert_eq![Int(4), Int(-64_i8).gcd(36)];
assert_eq![Int(4), Int(64_i8).gcd(-36)];
assert_eq![Int(4), Int(-64_i8).gcd(-36)];
assert_eq![Int(36), Int(0_i8).gcd(36)];
assert_eq![Int(64), Int(64_i8).gcd(0)];
Source

pub const fn gcd_ext(self, b: i8) -> GcdReturn<Int<i8>, Int<i8>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_i8).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: i8) -> GcdReturn<Int<i8>, Int<i8>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_i8).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: i8) -> Result<Int<i8>>

Returns the LCM.

Performs operations internally as i16 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_i8).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_i8).lcm(15), Ok(Int(60))];
assert_eq![Int(12_i8).lcm(-15), Ok(Int(60))];
Source

pub const fn scale(self, min: i8, max: i8, a: i8, b: i8) -> Result<Int<i8>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i16 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_i8).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_i8).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: i8, max: i8, a: i8, b: i8) -> Int<i8>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i16.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_i8).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_i8).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: i8) -> Int<i8>

Available on crate feature _int_u8 only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_i8).midpoint(4), 2];
assert_eq![Int(0_i8).midpoint(-1), -1];
assert_eq![Int(-1_i8).midpoint(0), -1];
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn abs(self) -> Int<i16>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_i16).is_even()];
assert![Int(-2_i16).is_even()];
assert![!Int(3_i16).is_even()];
assert![Int(0_i16).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_i16).is_odd()];
assert![Int(-3_i16).is_odd()];
assert![!Int(2_i16).is_odd()];
assert![!Int(0_i16).is_odd()];
Source

pub const fn gcd(self, b: i16) -> Int<i16>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_i16).gcd(36)];
assert_eq![Int(4), Int(-64_i16).gcd(36)];
assert_eq![Int(4), Int(64_i16).gcd(-36)];
assert_eq![Int(4), Int(-64_i16).gcd(-36)];
assert_eq![Int(36), Int(0_i16).gcd(36)];
assert_eq![Int(64), Int(64_i16).gcd(0)];
Source

pub const fn gcd_ext(self, b: i16) -> GcdReturn<Int<i16>, Int<i16>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_i16).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: i16) -> GcdReturn<Int<i16>, Int<i16>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_i16).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: i16) -> Result<Int<i16>>

Returns the LCM.

Performs operations internally as i32 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_i16).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_i16).lcm(15), Ok(Int(60))];
assert_eq![Int(12_i16).lcm(-15), Ok(Int(60))];
Source

pub const fn scale(self, min: i16, max: i16, a: i16, b: i16) -> Result<Int<i16>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i32 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_i16).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_i16).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: i16, max: i16, a: i16, b: i16) -> Int<i16>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i32.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_i16).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_i16).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: i16) -> Int<i16>

Available on crate feature _int_u16 only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_i16).midpoint(4), 2];
assert_eq![Int(0_i16).midpoint(-1), -1];
assert_eq![Int(-1_i16).midpoint(0), -1];
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn abs(self) -> Int<i32>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_i32).is_even()];
assert![Int(-2_i32).is_even()];
assert![!Int(3_i32).is_even()];
assert![Int(0_i32).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_i32).is_odd()];
assert![Int(-3_i32).is_odd()];
assert![!Int(2_i32).is_odd()];
assert![!Int(0_i32).is_odd()];
Source

pub const fn gcd(self, b: i32) -> Int<i32>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_i32).gcd(36)];
assert_eq![Int(4), Int(-64_i32).gcd(36)];
assert_eq![Int(4), Int(64_i32).gcd(-36)];
assert_eq![Int(4), Int(-64_i32).gcd(-36)];
assert_eq![Int(36), Int(0_i32).gcd(36)];
assert_eq![Int(64), Int(64_i32).gcd(0)];
Source

pub const fn gcd_ext(self, b: i32) -> GcdReturn<Int<i32>, Int<i32>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_i32).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: i32) -> GcdReturn<Int<i32>, Int<i32>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_i32).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: i32) -> Result<Int<i32>>

Returns the LCM.

Performs operations internally as i64 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_i32).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_i32).lcm(15), Ok(Int(60))];
assert_eq![Int(12_i32).lcm(-15), Ok(Int(60))];
Source

pub const fn scale(self, min: i32, max: i32, a: i32, b: i32) -> Result<Int<i32>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i64 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_i32).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_i32).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: i32, max: i32, a: i32, b: i32) -> Int<i32>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i64.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_i32).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_i32).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: i32) -> Int<i32>

Available on crate feature _int_u32 only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_i32).midpoint(4), 2];
assert_eq![Int(0_i32).midpoint(-1), -1];
assert_eq![Int(-1_i32).midpoint(0), -1];
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn abs(self) -> Int<i64>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_i64).is_even()];
assert![Int(-2_i64).is_even()];
assert![!Int(3_i64).is_even()];
assert![Int(0_i64).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_i64).is_odd()];
assert![Int(-3_i64).is_odd()];
assert![!Int(2_i64).is_odd()];
assert![!Int(0_i64).is_odd()];
Source

pub const fn gcd(self, b: i64) -> Int<i64>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_i64).gcd(36)];
assert_eq![Int(4), Int(-64_i64).gcd(36)];
assert_eq![Int(4), Int(64_i64).gcd(-36)];
assert_eq![Int(4), Int(-64_i64).gcd(-36)];
assert_eq![Int(36), Int(0_i64).gcd(36)];
assert_eq![Int(64), Int(64_i64).gcd(0)];
Source

pub const fn gcd_ext(self, b: i64) -> GcdReturn<Int<i64>, Int<i64>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_i64).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: i64) -> GcdReturn<Int<i64>, Int<i64>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_i64).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: i64) -> Result<Int<i64>>

Returns the LCM.

Performs operations internally as i128 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_i64).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_i64).lcm(15), Ok(Int(60))];
assert_eq![Int(12_i64).lcm(-15), Ok(Int(60))];
Source

pub const fn scale(self, min: i64, max: i64, a: i64, b: i64) -> Result<Int<i64>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i128 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_i64).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_i64).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: i64, max: i64, a: i64, b: i64) -> Int<i64>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i128.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_i64).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_i64).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: i64) -> Int<i64>

Available on crate feature _int_u64 only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_i64).midpoint(4), 2];
assert_eq![Int(0_i64).midpoint(-1), -1];
assert_eq![Int(-1_i64).midpoint(0), -1];
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn abs(self) -> Int<i128>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_i128).is_even()];
assert![Int(-2_i128).is_even()];
assert![!Int(3_i128).is_even()];
assert![Int(0_i128).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_i128).is_odd()];
assert![Int(-3_i128).is_odd()];
assert![!Int(2_i128).is_odd()];
assert![!Int(0_i128).is_odd()];
Source

pub const fn gcd(self, b: i128) -> Int<i128>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_i128).gcd(36)];
assert_eq![Int(4), Int(-64_i128).gcd(36)];
assert_eq![Int(4), Int(64_i128).gcd(-36)];
assert_eq![Int(4), Int(-64_i128).gcd(-36)];
assert_eq![Int(36), Int(0_i128).gcd(36)];
assert_eq![Int(64), Int(64_i128).gcd(0)];
Source

pub const fn gcd_ext(self, b: i128) -> GcdReturn<Int<i128>, Int<i128>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_i128).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: i128) -> GcdReturn<Int<i128>, Int<i128>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_i128).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: i128) -> Result<Int<i128>>

Returns the LCM.

Performs operations internally as i128 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_i128).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_i128).lcm(15), Ok(Int(60))];
assert_eq![Int(12_i128).lcm(-15), Ok(Int(60))];
Source

pub const fn scale( self, min: i128, max: i128, a: i128, b: i128, ) -> Result<Int<i128>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i128 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_i128).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_i128).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap( self, min: i128, max: i128, a: i128, b: i128, ) -> Int<i128>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as i128.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_i128).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_i128).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: i128) -> Int<i128>

Available on crate feature _int_u128 only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_i128).midpoint(4), 2];
assert_eq![Int(0_i128).midpoint(-1), -1];
assert_eq![Int(-1_i128).midpoint(0), -1];
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn abs(self) -> Int<isize>

Returns the absolute value of self.

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_isize).is_even()];
assert![Int(-2_isize).is_even()];
assert![!Int(3_isize).is_even()];
assert![Int(0_isize).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_isize).is_odd()];
assert![Int(-3_isize).is_odd()];
assert![!Int(2_isize).is_odd()];
assert![!Int(0_isize).is_odd()];
Source

pub const fn gcd(self, b: isize) -> Int<isize>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_isize).gcd(36)];
assert_eq![Int(4), Int(-64_isize).gcd(36)];
assert_eq![Int(4), Int(64_isize).gcd(-36)];
assert_eq![Int(4), Int(-64_isize).gcd(-36)];
assert_eq![Int(36), Int(0_isize).gcd(36)];
assert_eq![Int(64), Int(64_isize).gcd(0)];
Source

pub const fn gcd_ext(self, b: isize) -> GcdReturn<Int<isize>, Int<isize>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Examples
let (gcd, x, y) = Int(32_isize).gcd_ext(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn gcd_ext_euc(self, b: isize) -> GcdReturn<Int<isize>, Int<isize>>

Returns the GCD and the Bézout coeficients.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Examples
let (gcd, x, y) = Int(32_isize).gcd_ext_euc(36).as_tuple();
assert_eq!(gcd.0, 4);
assert_eq!(x.0 * 32 + y.0 * 36, gcd.0);
Source

pub const fn lcm(self, b: isize) -> Result<Int<isize>>

Returns the LCM.

Performs operations internally as isize_up for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_isize).lcm(15), Ok(Int(60))];
assert_eq![Int(-12_isize).lcm(15), Ok(Int(60))];
assert_eq![Int(12_isize).lcm(-15), Ok(Int(60))];
Source

pub const fn scale( self, min: isize, max: isize, a: isize, b: isize, ) -> Result<Int<isize>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as isize_up for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_isize).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_isize).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(100_i8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap( self, min: isize, max: isize, a: isize, b: isize, ) -> Int<isize>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as isize_up.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_isize).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_isize).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(-76), Int(100_i8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: isize) -> Int<isize>

Available on crate feature _int_usize only.

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_isize).midpoint(4), 2];
assert_eq![Int(0_isize).midpoint(-1), -1];
assert_eq![Int(-1_isize).midpoint(0), -1];
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn abs(self) -> Int<u8>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_u8).is_even()];
assert![!Int(3_u8).is_even()];
assert![Int(0_u8).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_u8).is_odd()];
assert![!Int(2_u8).is_odd()];
assert![!Int(0_u8).is_odd()];
Source

pub const fn gcd(self, b: u8) -> Int<u8>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_u8).gcd(36)];
assert_eq![Int(36), Int(0_u8).gcd(36)];
assert_eq![Int(64), Int(64_u8).gcd(0)];
Source

pub const fn gcd_ext(self, b: u8) -> Result<GcdReturn<Int<u8>, Int<i16>>>

Available on crate features _int_i16 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i16.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u8).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i16];
Source

pub const fn gcd_ext_euc(self, b: u8) -> Result<GcdReturn<Int<u8>, Int<i16>>>

Available on crate features _int_i16 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i16.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u8).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i16];
Source

pub const fn lcm(self, b: u8) -> Result<Int<u8>>

Returns the LCM.

Performs operations internally as u16 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_u8).lcm(15), Ok(Int(60))];
Source

pub const fn scale(self, min: u8, max: u8, a: u8, b: u8) -> Result<Int<u8>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u16 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_u8).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_u8).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: u8, max: u8, a: u8, b: u8) -> Int<u8>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u16.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_u8).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_u8).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: u8) -> Int<u8>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_u8).midpoint(4), 2];
assert_eq![Int(1_u8).midpoint(4), 2];
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn abs(self) -> Int<u16>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_u16).is_even()];
assert![!Int(3_u16).is_even()];
assert![Int(0_u16).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_u16).is_odd()];
assert![!Int(2_u16).is_odd()];
assert![!Int(0_u16).is_odd()];
Source

pub const fn gcd(self, b: u16) -> Int<u16>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_u16).gcd(36)];
assert_eq![Int(36), Int(0_u16).gcd(36)];
assert_eq![Int(64), Int(64_u16).gcd(0)];
Source

pub const fn gcd_ext(self, b: u16) -> Result<GcdReturn<Int<u16>, Int<i32>>>

Available on crate features _int_i32 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i32.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u16).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i32];
Source

pub const fn gcd_ext_euc(self, b: u16) -> Result<GcdReturn<Int<u16>, Int<i32>>>

Available on crate features _int_i32 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i32.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u16).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i32];
Source

pub const fn lcm(self, b: u16) -> Result<Int<u16>>

Returns the LCM.

Performs operations internally as u32 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_u16).lcm(15), Ok(Int(60))];
Source

pub const fn scale(self, min: u16, max: u16, a: u16, b: u16) -> Result<Int<u16>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u32 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_u16).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_u16).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: u16, max: u16, a: u16, b: u16) -> Int<u16>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u32.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_u16).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_u16).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: u16) -> Int<u16>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_u16).midpoint(4), 2];
assert_eq![Int(1_u16).midpoint(4), 2];
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn abs(self) -> Int<u32>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_u32).is_even()];
assert![!Int(3_u32).is_even()];
assert![Int(0_u32).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_u32).is_odd()];
assert![!Int(2_u32).is_odd()];
assert![!Int(0_u32).is_odd()];
Source

pub const fn gcd(self, b: u32) -> Int<u32>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_u32).gcd(36)];
assert_eq![Int(36), Int(0_u32).gcd(36)];
assert_eq![Int(64), Int(64_u32).gcd(0)];
Source

pub const fn gcd_ext(self, b: u32) -> Result<GcdReturn<Int<u32>, Int<i64>>>

Available on crate features _int_i64 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i64.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u32).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i64];
Source

pub const fn gcd_ext_euc(self, b: u32) -> Result<GcdReturn<Int<u32>, Int<i64>>>

Available on crate features _int_i64 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i64.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u32).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i64];
Source

pub const fn lcm(self, b: u32) -> Result<Int<u32>>

Returns the LCM.

Performs operations internally as u64 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_u32).lcm(15), Ok(Int(60))];
Source

pub const fn scale(self, min: u32, max: u32, a: u32, b: u32) -> Result<Int<u32>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u64 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_u32).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_u32).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: u32, max: u32, a: u32, b: u32) -> Int<u32>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u64.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_u32).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_u32).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: u32) -> Int<u32>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_u32).midpoint(4), 2];
assert_eq![Int(1_u32).midpoint(4), 2];
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn abs(self) -> Int<u64>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_u64).is_even()];
assert![!Int(3_u64).is_even()];
assert![Int(0_u64).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_u64).is_odd()];
assert![!Int(2_u64).is_odd()];
assert![!Int(0_u64).is_odd()];
Source

pub const fn gcd(self, b: u64) -> Int<u64>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_u64).gcd(36)];
assert_eq![Int(36), Int(0_u64).gcd(36)];
assert_eq![Int(64), Int(64_u64).gcd(0)];
Source

pub const fn gcd_ext(self, b: u64) -> Result<GcdReturn<Int<u64>, Int<i128>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i128.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u64).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i128];
Source

pub const fn gcd_ext_euc(self, b: u64) -> Result<GcdReturn<Int<u64>, Int<i128>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i128.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u64).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i128];
Source

pub const fn lcm(self, b: u64) -> Result<Int<u64>>

Returns the LCM.

Performs operations internally as u128 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_u64).lcm(15), Ok(Int(60))];
Source

pub const fn scale(self, min: u64, max: u64, a: u64, b: u64) -> Result<Int<u64>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u128 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_u64).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_u64).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap(self, min: u64, max: u64, a: u64, b: u64) -> Int<u64>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u128.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_u64).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_u64).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: u64) -> Int<u64>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_u64).midpoint(4), 2];
assert_eq![Int(1_u64).midpoint(4), 2];
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn abs(self) -> Int<u128>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_u128).is_even()];
assert![!Int(3_u128).is_even()];
assert![Int(0_u128).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_u128).is_odd()];
assert![!Int(2_u128).is_odd()];
assert![!Int(0_u128).is_odd()];
Source

pub const fn gcd(self, b: u128) -> Int<u128>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_u128).gcd(36)];
assert_eq![Int(36), Int(0_u128).gcd(36)];
assert_eq![Int(64), Int(64_u128).gcd(0)];
Source

pub const fn gcd_ext(self, b: u128) -> Result<GcdReturn<Int<u128>, Int<i128>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i128.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u128).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i128];
Source

pub const fn gcd_ext_euc( self, b: u128, ) -> Result<GcdReturn<Int<u128>, Int<i128>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as i128.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_u128).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as i128];
Source

pub const fn lcm(self, b: u128) -> Result<Int<u128>>

Returns the LCM.

Performs operations internally as u128 for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_u128).lcm(15), Ok(Int(60))];
Source

pub const fn scale( self, min: u128, max: u128, a: u128, b: u128, ) -> Result<Int<u128>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u128 for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_u128).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_u128).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap( self, min: u128, max: u128, a: u128, b: u128, ) -> Int<u128>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as u128.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_u128).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_u128).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: u128) -> Int<u128>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_u128).midpoint(4), 2];
assert_eq![Int(1_u128).midpoint(4), 2];
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn abs(self) -> Int<usize>

Returns the absolute value of self (no-op).

Source

pub const fn is_even(self) -> bool

Returns true if self is an even number.

§Examples
assert![Int(2_usize).is_even()];
assert![!Int(3_usize).is_even()];
assert![Int(0_usize).is_even()];
Source

pub const fn is_odd(self) -> bool

Returns true if self is an odd number.

§Examples
assert![Int(3_usize).is_odd()];
assert![!Int(2_usize).is_odd()];
assert![!Int(0_usize).is_odd()];
Source

pub const fn gcd(self, b: usize) -> Int<usize>

Returns the GCD.

Uses Stein’s algorithm which is much more efficient to compute than Euclid’s.

§Examples
assert_eq![Int(4), Int(64_usize).gcd(36)];
assert_eq![Int(36), Int(0_usize).gcd(36)];
assert_eq![Int(64), Int(64_usize).gcd(0)];
Source

pub const fn gcd_ext( self, b: usize, ) -> Result<GcdReturn<Int<usize>, Int<isize_up>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as isize_up.

This version uses the extended Stein’s algorithm which is much more efficient to compute than Euclid’s. It uses only simple arithmetic operations and works by dividing the inputs by 2 until they are odd, and then subtracting the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

Bézout’s identity states that for any two integers a and b, there exist integers x and y such that $ax + by = gcd(a, b)$.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_usize).gcd_ext(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as isize_up];
Source

pub const fn gcd_ext_euc( self, b: usize, ) -> Result<GcdReturn<Int<usize>, Int<isize_up>>>

Available on crate features _int_i128 and cast only.

Returns the GCD and the Bézout coeficients.

Performs inner operations and returns coefficients as isize_up.

This version uses the extended Euclids’s algorithm, which uses a series of euclidean divisions and works by subtracting multiples of the smaller number from the larger one.

The Bézout’s coefficients are not unique, and different algorithms can yield different coefficients that all satisfy Bézout’s identity.

§Errors

Can return Overflow for u128.

§Examples
let (gcd, x, y) = Int(32_usize).gcd_ext_euc(36).unwrap().as_tuple();
assert_eq!(gcd.0, 4);
assert_eq![x.0 * 32 + y.0 * 36, gcd.0 as isize_up];
Source

pub const fn lcm(self, b: usize) -> Result<Int<usize>>

Returns the LCM.

Performs operations internally as usize_up for the inner operations.

§Errors

Can Overflow.

§Examples
assert_eq![Int(12_usize).lcm(15), Ok(Int(60))];
Source

pub const fn scale( self, min: usize, max: usize, a: usize, b: usize, ) -> Result<Int<usize>>

Available on crate feature cast only.

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as usize_up for the checked operations.

If the value lies outside of [min..=max] it will result in extrapolation.

§Errors

Can Overflow for extrapolated values that can’t fit the type, and for overflowing arithmetic operations in the following formula:

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Ok(Int(40)), Int(60_usize).scale(0, 120, 30, 50)]; // interpolate
assert_eq![Ok(Int(112)), Int(100_usize).scale(0, 80, 0, 90)]; // extrapolate
assert![Int(200_u8).scale(0, 50, 0, 90).is_err()]; // extrapolate and overflow
Source

pub const fn scale_wrap( self, min: usize, max: usize, a: usize, b: usize, ) -> Int<usize>

Returns a scaled value between [min..=max] to a new range [a..=b].

Performs operations internally as usize_up.

If the value lies outside of [min..=max] it will result in extrapolation, and if the value doesn’t fit in the type it will wrap around its boundaries.

§Panics

Could panic for large values of i128 or u128.

§Formula

$$ \large v’ = (b - a) \frac{v - min}{max - min} + a $$

§Examples
assert_eq![Int(40), Int(60_usize).scale_wrap(0, 120, 30, 50)]; // interpolate
assert_eq![Int(112), Int(100_usize).scale_wrap(0, 80, 0, 90)]; // extrapolate
assert_eq![Int(104), Int(200_u8).scale_wrap(0, 50, 0, 90)]; // extrapolate and wrap
Source

pub const fn midpoint(self, other: usize) -> Int<usize>

Calculates the middle point of self and other.

The result is always rounded towards negative infinity.

§Examples
assert_eq![Int(0_usize).midpoint(4), 2];
assert_eq![Int(1_usize).midpoint(4), 2];
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn div_rem(self, b: i8) -> [Int<i8>; 2]

Available on crate feature _int_i8 only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_i8).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_i8).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_i8).div_ceil(3), Int(-2)];
assert_eq![Int(-7_i8).div_ceil(-3), Int(3)];

assert_eq![Int(7_i8).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_i8).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_i8).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_i8).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i8).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i8).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i8).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_i8).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_i8).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i8).div_floor(-3), Int(-3)];
assert_eq![Int(-7_i8).div_floor(3), Int(-3)];
assert_eq![Int(-7_i8).div_floor(-3), Int(2)];

assert_eq![Int(7_i8).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_i8).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_i8).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_i8).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i8).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_i8).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i8).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i8).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_i8).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i8).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_away(-3), Int(2)];

assert_eq![Int(7_i8).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_i8).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_i8).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_i8).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i8).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i8).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i8).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i8).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_i8).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i8).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_i8).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_i8).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_i8).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_i8).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i8).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i8).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i8).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i8).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_i8).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i8).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_even(-3), Int(2)];

assert_eq![Int(7_i8).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_i8).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_i8).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_i8).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i8).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i8).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i8).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i8).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: i8) -> Int<i8>

Available on crate feature _int_i8 only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_i8).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i8).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_i8).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_i8).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_i8).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_i8).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_i8).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i8).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i8).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i8).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i8).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn div_rem(self, b: i16) -> [Int<i16>; 2]

Available on crate feature _int_i16 only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_i16).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_i16).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_i16).div_ceil(3), Int(-2)];
assert_eq![Int(-7_i16).div_ceil(-3), Int(3)];

assert_eq![Int(7_i16).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_i16).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_i16).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_i16).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i16).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i16).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i16).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_i16).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_i16).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i16).div_floor(-3), Int(-3)];
assert_eq![Int(-7_i16).div_floor(3), Int(-3)];
assert_eq![Int(-7_i16).div_floor(-3), Int(2)];

assert_eq![Int(7_i16).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_i16).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_i16).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_i16).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i16).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_i16).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i16).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i16).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_i16).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i16).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_away(-3), Int(2)];

assert_eq![Int(7_i16).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_i16).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_i16).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_i16).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i16).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i16).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i16).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i16).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_i16).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i16).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_i16).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_i16).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_i16).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_i16).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i16).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i16).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i16).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i16).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_i16).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i16).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_even(-3), Int(2)];

assert_eq![Int(7_i16).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_i16).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_i16).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_i16).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i16).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i16).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i16).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i16).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: i16) -> Int<i16>

Available on crate feature _int_i16 only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_i16).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i16).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_i16).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_i16).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_i16).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_i16).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_i16).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i16).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i16).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i16).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i16).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn div_rem(self, b: i32) -> [Int<i32>; 2]

Available on crate feature _int_i32 only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_i32).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_i32).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_i32).div_ceil(3), Int(-2)];
assert_eq![Int(-7_i32).div_ceil(-3), Int(3)];

assert_eq![Int(7_i32).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_i32).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_i32).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_i32).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i32).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i32).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i32).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_i32).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_i32).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i32).div_floor(-3), Int(-3)];
assert_eq![Int(-7_i32).div_floor(3), Int(-3)];
assert_eq![Int(-7_i32).div_floor(-3), Int(2)];

assert_eq![Int(7_i32).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_i32).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_i32).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_i32).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i32).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_i32).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i32).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i32).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_i32).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i32).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_away(-3), Int(2)];

assert_eq![Int(7_i32).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_i32).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_i32).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_i32).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i32).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i32).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i32).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i32).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_i32).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i32).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_i32).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_i32).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_i32).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_i32).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i32).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i32).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i32).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i32).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_i32).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i32).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_even(-3), Int(2)];

assert_eq![Int(7_i32).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_i32).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_i32).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_i32).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i32).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i32).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i32).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i32).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: i32) -> Int<i32>

Available on crate feature _int_i32 only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_i32).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i32).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_i32).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_i32).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_i32).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_i32).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_i32).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i32).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i32).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i32).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i32).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn div_rem(self, b: i64) -> [Int<i64>; 2]

Available on crate feature _int_i64 only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_i64).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_i64).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_i64).div_ceil(3), Int(-2)];
assert_eq![Int(-7_i64).div_ceil(-3), Int(3)];

assert_eq![Int(7_i64).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_i64).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_i64).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_i64).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i64).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i64).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i64).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_i64).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_i64).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i64).div_floor(-3), Int(-3)];
assert_eq![Int(-7_i64).div_floor(3), Int(-3)];
assert_eq![Int(-7_i64).div_floor(-3), Int(2)];

assert_eq![Int(7_i64).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_i64).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_i64).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_i64).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i64).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_i64).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i64).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i64).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_i64).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i64).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_away(-3), Int(2)];

assert_eq![Int(7_i64).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_i64).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_i64).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_i64).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i64).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i64).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i64).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i64).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_i64).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i64).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_i64).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_i64).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_i64).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_i64).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i64).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i64).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i64).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i64).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_i64).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i64).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_even(-3), Int(2)];

assert_eq![Int(7_i64).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_i64).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_i64).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_i64).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i64).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i64).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i64).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i64).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: i64) -> Int<i64>

Available on crate feature _int_i64 only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_i64).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i64).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_i64).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_i64).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_i64).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_i64).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_i64).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i64).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i64).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i64).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i64).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn div_rem(self, b: i128) -> [Int<i128>; 2]

Available on crate feature _int_i128 only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_i128).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_i128).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_i128).div_ceil(3), Int(-2)];
assert_eq![Int(-7_i128).div_ceil(-3), Int(3)];

assert_eq![Int(7_i128).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_i128).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_i128).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_i128).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i128).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i128).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i128).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_i128).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_i128).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i128).div_floor(-3), Int(-3)];
assert_eq![Int(-7_i128).div_floor(3), Int(-3)];
assert_eq![Int(-7_i128).div_floor(-3), Int(2)];

assert_eq![Int(7_i128).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_i128).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_i128).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_i128).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i128).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_i128).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i128).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i128).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_i128).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i128).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_away(-3), Int(2)];

assert_eq![Int(7_i128).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_i128).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_i128).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_i128).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i128).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i128).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i128).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i128).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_i128).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i128).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_i128).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_i128).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_i128).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_i128).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i128).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i128).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i128).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i128).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_i128).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i128).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_even(-3), Int(2)];

assert_eq![Int(7_i128).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_i128).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_i128).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_i128).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_i128).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i128).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_i128).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i128).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: i128) -> Int<i128>

Available on crate feature _int_i128 only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_i128).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_i128).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_i128).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_i128).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_i128).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_i128).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_i128).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_i128).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_i128).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_i128).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_i128).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn div_rem(self, b: isize) -> [Int<isize>; 2]

Available on crate feature _int_isize only.

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Formulation

$$ \large \text{div\_ceil}(a, b) = \begin{cases} \left\lfloor \frac{a}{b} \right\rfloor + 1 & \text{if } (r > 0 \land b > 0) \lor (r < 0 \land b < 0), \cr \left\lfloor \frac{a}{b} \right\rfloor & \text{otherwise.} \end{cases} $$

§Examples
assert_eq![Int(7_isize).div_ceil(3), Int(3)]; // == 2.33…
assert_eq![Int(7_isize).div_ceil(-3), Int(-2)];
assert_eq![Int(-7_isize).div_ceil(3), Int(-2)];
assert_eq![Int(-7_isize).div_ceil(-3), Int(3)];

assert_eq![Int(7_isize).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_isize).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_isize).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_isize).div_ceil(2), Int(3)]; // == 2.5
assert_eq![Int(-7_isize).div_ceil(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_isize).div_ceil(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_isize).div_ceil(5), Int(-1)]; // == -1.6
assert_eq![Int(-5_isize).div_ceil(2), Int(-2)]; // == -2.5
Source

pub const fn div_floor(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_isize).div_floor(3), Int(2)]; // == 2.33…
assert_eq![Int(7_isize).div_floor(-3), Int(-3)];
assert_eq![Int(-7_isize).div_floor(3), Int(-3)];
assert_eq![Int(-7_isize).div_floor(-3), Int(2)];

assert_eq![Int(7_isize).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_isize).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_isize).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_isize).div_floor(2), Int(2)]; // == 2.5
assert_eq![Int(-7_isize).div_floor(5), Int(-2)]; // == -1.4
assert_eq![Int(-6_isize).div_floor(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_isize).div_floor(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_isize).div_floor(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_away(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_isize).div_ties_away(3), Int(2)]; // == 2.33…
assert_eq![Int(7_isize).div_ties_away(-3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_away(3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_away(-3), Int(2)];

assert_eq![Int(7_isize).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_isize).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_isize).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_isize).div_ties_away(2), Int(3)]; // == 2.5
assert_eq![Int(-7_isize).div_ties_away(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_isize).div_ties_away(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_isize).div_ties_away(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_isize).div_ties_away(2), Int(-3)]; // == -2.5
Source

pub const fn div_ties_towards(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_isize).div_ties_towards(3), Int(2)]; // == 2.33…
assert_eq![Int(7_isize).div_ties_towards(-3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_towards(3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_towards(-3), Int(2)];

assert_eq![Int(7_isize).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_isize).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_isize).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_isize).div_ties_towards(2), Int(2)]; // == 2.5
assert_eq![Int(-7_isize).div_ties_towards(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_isize).div_ties_towards(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_isize).div_ties_towards(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_isize).div_ties_towards(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_even(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_isize).div_ties_even(3), Int(2)]; // == 2.33…
assert_eq![Int(7_isize).div_ties_even(-3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_even(3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_even(-3), Int(2)];

assert_eq![Int(7_isize).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_isize).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_isize).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_isize).div_ties_even(2), Int(2)]; // == 2.5
assert_eq![Int(-7_isize).div_ties_even(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_isize).div_ties_even(4), Int(-2)]; // == -1.5
assert_eq![Int(-8_isize).div_ties_even(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_isize).div_ties_even(2), Int(-2)]; // == -2.5
Source

pub const fn div_ties_odd(self, b: isize) -> Int<isize>

Available on crate feature _int_isize only.

Returns the quotient, rounding ties to the nearest odd number.

§Examples
assert_eq![Int(7_isize).div_ties_odd(3), Int(2)]; // == 2.33…
assert_eq![Int(7_isize).div_ties_odd(-3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_odd(3), Int(-2)];
assert_eq![Int(-7_isize).div_ties_odd(-3), Int(2)];

assert_eq![Int(7_isize).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_isize).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_isize).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_isize).div_ties_odd(2), Int(3)]; // == 2.5
assert_eq![Int(-7_isize).div_ties_odd(5), Int(-1)]; // == -1.4
assert_eq![Int(-6_isize).div_ties_odd(4), Int(-1)]; // == -1.5
assert_eq![Int(-8_isize).div_ties_odd(5), Int(-2)]; // == -1.6
assert_eq![Int(-5_isize).div_ties_odd(2), Int(-3)]; // == -2.5
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn div_rem(self, b: u8) -> [Int<u8>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: u8) -> Int<u8>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_u8).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_u8).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_u8).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_u8).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_u8).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: u8) -> Int<u8>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_u8).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u8).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_u8).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_u8).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_u8).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: u8) -> Int<u8>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_u8).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u8).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_u8).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_u8).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_u8).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: u8) -> Int<u8>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_u8).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u8).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_u8).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_u8).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_u8).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: u8) -> Int<u8>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u8).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u8).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_u8).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_u8).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_u8).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: u8) -> Int<u8>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u8).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u8).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_u8).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_u8).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_u8).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn div_rem(self, b: u16) -> [Int<u16>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: u16) -> Int<u16>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_u16).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_u16).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_u16).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_u16).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_u16).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: u16) -> Int<u16>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_u16).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u16).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_u16).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_u16).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_u16).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: u16) -> Int<u16>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_u16).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u16).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_u16).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_u16).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_u16).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: u16) -> Int<u16>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_u16).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u16).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_u16).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_u16).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_u16).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: u16) -> Int<u16>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u16).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u16).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_u16).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_u16).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_u16).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: u16) -> Int<u16>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u16).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u16).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_u16).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_u16).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_u16).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn div_rem(self, b: u32) -> [Int<u32>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: u32) -> Int<u32>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_u32).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_u32).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_u32).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_u32).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_u32).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: u32) -> Int<u32>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_u32).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u32).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_u32).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_u32).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_u32).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: u32) -> Int<u32>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_u32).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u32).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_u32).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_u32).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_u32).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: u32) -> Int<u32>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_u32).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u32).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_u32).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_u32).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_u32).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: u32) -> Int<u32>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u32).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u32).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_u32).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_u32).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_u32).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: u32) -> Int<u32>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u32).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u32).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_u32).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_u32).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_u32).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn div_rem(self, b: u64) -> [Int<u64>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: u64) -> Int<u64>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_u64).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_u64).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_u64).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_u64).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_u64).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: u64) -> Int<u64>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_u64).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u64).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_u64).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_u64).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_u64).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: u64) -> Int<u64>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_u64).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u64).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_u64).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_u64).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_u64).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: u64) -> Int<u64>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_u64).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u64).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_u64).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_u64).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_u64).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: u64) -> Int<u64>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u64).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u64).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_u64).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_u64).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_u64).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: u64) -> Int<u64>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u64).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u64).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_u64).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_u64).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_u64).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn div_rem(self, b: u128) -> [Int<u128>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: u128) -> Int<u128>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_u128).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_u128).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_u128).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_u128).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_u128).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: u128) -> Int<u128>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_u128).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u128).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_u128).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_u128).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_u128).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: u128) -> Int<u128>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_u128).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u128).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_u128).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_u128).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_u128).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: u128) -> Int<u128>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_u128).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u128).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_u128).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_u128).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_u128).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: u128) -> Int<u128>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u128).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u128).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_u128).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_u128).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_u128).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: u128) -> Int<u128>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_u128).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_u128).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_u128).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_u128).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_u128).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn div_rem(self, b: usize) -> [Int<usize>; 2]

Returns the truncated quotient and the remainder.

Source

pub const fn div_ceil(self, b: usize) -> Int<usize>

Returns the quotient, rounding the result towards positive infinity. $$ \large \left\lceil \frac{x}{y} \right\rceil $$

§Examples
assert_eq![Int(7_usize).div_ceil(3), Int(3)]; // == 2.33…

assert_eq![Int(7_usize).div_ceil(5), Int(2)]; // == 1.4
assert_eq![Int(6_usize).div_ceil(4), Int(2)]; // == 1.5
assert_eq![Int(8_usize).div_ceil(5), Int(2)]; // == 1.6
assert_eq![Int(5_usize).div_ceil(2), Int(3)]; // == 2.5
Source

pub const fn div_floor(self, b: usize) -> Int<usize>

Returns the quotient, rounding the result towards negative infinity. $$ \large \left\lfloor \frac{x}{y} \right\rfloor $$

§Examples
assert_eq![Int(7_usize).div_floor(3), Int(2)]; // == 2.33…

assert_eq![Int(7_usize).div_floor(5), Int(1)]; // == 1.4
assert_eq![Int(6_usize).div_floor(4), Int(1)]; // == 1.5
assert_eq![Int(8_usize).div_floor(5), Int(1)]; // == 1.6
assert_eq![Int(5_usize).div_floor(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_away(self, b: usize) -> Int<usize>

Returns the quotient, rounding ties away from zero.

§Examples
assert_eq![Int(7_usize).div_ties_away(3), Int(2)]; // == 2.33…

assert_eq![Int(7_usize).div_ties_away(5), Int(1)]; // == 1.4
assert_eq![Int(6_usize).div_ties_away(4), Int(2)]; // == 1.5
assert_eq![Int(8_usize).div_ties_away(5), Int(2)]; // == 1.6
assert_eq![Int(5_usize).div_ties_away(2), Int(3)]; // == 2.5
Source

pub const fn div_ties_towards(self, b: usize) -> Int<usize>

Returns the quotient, rounding ties towards zero.

§Examples
assert_eq![Int(7_usize).div_ties_towards(3), Int(2)]; // == 2.33…

assert_eq![Int(7_usize).div_ties_towards(5), Int(1)]; // == 1.4
assert_eq![Int(6_usize).div_ties_towards(4), Int(1)]; // == 1.5
assert_eq![Int(8_usize).div_ties_towards(5), Int(2)]; // == 1.6
assert_eq![Int(5_usize).div_ties_towards(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_even(self, b: usize) -> Int<usize>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_usize).div_ties_even(3), Int(2)]; // == 2.33…

assert_eq![Int(7_usize).div_ties_even(5), Int(1)]; // == 1.4
assert_eq![Int(6_usize).div_ties_even(4), Int(2)]; // == 1.5
assert_eq![Int(8_usize).div_ties_even(5), Int(2)]; // == 1.6
assert_eq![Int(5_usize).div_ties_even(2), Int(2)]; // == 2.5
Source

pub const fn div_ties_odd(self, b: usize) -> Int<usize>

Returns the quotient, rounding ties to the nearest even number.

§Examples
assert_eq![Int(7_usize).div_ties_odd(3), Int(2)]; // == 2.33…

assert_eq![Int(7_usize).div_ties_odd(5), Int(1)]; // == 1.4
assert_eq![Int(6_usize).div_ties_odd(4), Int(1)]; // == 1.5
assert_eq![Int(8_usize).div_ties_odd(5), Int(2)]; // == 1.6
assert_eq![Int(5_usize).div_ties_odd(2), Int(3)]; // == 2.5
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub fn factors(self) -> Vec<i8>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_i8).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_i8).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_i8).factors().is_empty()];
assert_eq![Int(1_i8).factors(), vec![1]];
assert_eq![Int(7_i8).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<i8>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_i8).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_i8).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_i8).factors_proper().is_empty()];
assert![Int(1_i8).factors_proper().is_empty()];
assert![Int(7_i8).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<i8>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_i8).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_i8).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_i8).factors_prime().is_empty()];
assert![Int(1_i8).factors_prime().is_empty()];
assert_eq![Int(7_i8).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<i8>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_i8).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_i8).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(i8, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_i8).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_i8).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_i8).factors_prime_unique_exp().is_empty()];
assert![Int(1_i8).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_i8).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_i8).factors_prime_count(), 4];
assert_eq![Int(-24_i8).factors_prime_count(), 4];
assert_eq![Int(0_i8).factors_prime_count(), 0];
assert_eq![Int(1_i8).factors_prime_count(), 0];
assert_eq![Int(7_i8).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_i8).factors_prime_unique_count(), 2];
assert_eq![Int(-24_i8).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [i8], upfbuf: &mut [i8], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i8).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [i8], upfbuf: &mut [i8], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i8).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [i8]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_i8).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_i8 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_i8).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_i8).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_i8).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [i8]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_i8).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [i8], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_i8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [i8], upfbuf: &mut [i8], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_i8).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub fn factors(self) -> Vec<i16>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_i16).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_i16).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_i16).factors().is_empty()];
assert_eq![Int(1_i16).factors(), vec![1]];
assert_eq![Int(7_i16).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<i16>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_i16).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_i16).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_i16).factors_proper().is_empty()];
assert![Int(1_i16).factors_proper().is_empty()];
assert![Int(7_i16).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<i16>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_i16).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_i16).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_i16).factors_prime().is_empty()];
assert![Int(1_i16).factors_prime().is_empty()];
assert_eq![Int(7_i16).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<i16>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_i16).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_i16).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(i16, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_i16).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_i16).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_i16).factors_prime_unique_exp().is_empty()];
assert![Int(1_i16).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_i16).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_i16).factors_prime_count(), 4];
assert_eq![Int(-24_i16).factors_prime_count(), 4];
assert_eq![Int(0_i16).factors_prime_count(), 0];
assert_eq![Int(1_i16).factors_prime_count(), 0];
assert_eq![Int(7_i16).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_i16).factors_prime_unique_count(), 2];
assert_eq![Int(-24_i16).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [i16], upfbuf: &mut [i16], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i16).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [i16], upfbuf: &mut [i16], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i16).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [i16]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_i16).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_i16 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_i16).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_i16).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_i16).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [i16]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_i16).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [i16], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_i16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [i16], upfbuf: &mut [i16], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_i16).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub fn factors(self) -> Vec<i32>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_i32).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_i32).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_i32).factors().is_empty()];
assert_eq![Int(1_i32).factors(), vec![1]];
assert_eq![Int(7_i32).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<i32>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_i32).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_i32).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_i32).factors_proper().is_empty()];
assert![Int(1_i32).factors_proper().is_empty()];
assert![Int(7_i32).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<i32>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_i32).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_i32).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_i32).factors_prime().is_empty()];
assert![Int(1_i32).factors_prime().is_empty()];
assert_eq![Int(7_i32).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<i32>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_i32).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_i32).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(i32, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_i32).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_i32).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_i32).factors_prime_unique_exp().is_empty()];
assert![Int(1_i32).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_i32).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_i32).factors_prime_count(), 4];
assert_eq![Int(-24_i32).factors_prime_count(), 4];
assert_eq![Int(0_i32).factors_prime_count(), 0];
assert_eq![Int(1_i32).factors_prime_count(), 0];
assert_eq![Int(7_i32).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_i32).factors_prime_unique_count(), 2];
assert_eq![Int(-24_i32).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [i32], upfbuf: &mut [i32], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i32).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [i32], upfbuf: &mut [i32], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i32).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [i32]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_i32).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_i32 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_i32).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_i32).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_i32).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [i32]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_i32).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [i32], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_i32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [i32], upfbuf: &mut [i32], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_i32).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub fn factors(self) -> Vec<i64>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_i64).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_i64).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_i64).factors().is_empty()];
assert_eq![Int(1_i64).factors(), vec![1]];
assert_eq![Int(7_i64).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<i64>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_i64).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_i64).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_i64).factors_proper().is_empty()];
assert![Int(1_i64).factors_proper().is_empty()];
assert![Int(7_i64).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<i64>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_i64).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_i64).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_i64).factors_prime().is_empty()];
assert![Int(1_i64).factors_prime().is_empty()];
assert_eq![Int(7_i64).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<i64>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_i64).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_i64).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(i64, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_i64).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_i64).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_i64).factors_prime_unique_exp().is_empty()];
assert![Int(1_i64).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_i64).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_i64).factors_prime_count(), 4];
assert_eq![Int(-24_i64).factors_prime_count(), 4];
assert_eq![Int(0_i64).factors_prime_count(), 0];
assert_eq![Int(1_i64).factors_prime_count(), 0];
assert_eq![Int(7_i64).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_i64).factors_prime_unique_count(), 2];
assert_eq![Int(-24_i64).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [i64], upfbuf: &mut [i64], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i64).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [i64], upfbuf: &mut [i64], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i64).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [i64]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_i64).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_i64 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_i64).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_i64).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_i64).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [i64]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_i64).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [i64], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_i64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [i64], upfbuf: &mut [i64], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_i64).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub fn factors(self) -> Vec<i128>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_i128).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_i128).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_i128).factors().is_empty()];
assert_eq![Int(1_i128).factors(), vec![1]];
assert_eq![Int(7_i128).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<i128>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_i128).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_i128).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_i128).factors_proper().is_empty()];
assert![Int(1_i128).factors_proper().is_empty()];
assert![Int(7_i128).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<i128>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_i128).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_i128).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_i128).factors_prime().is_empty()];
assert![Int(1_i128).factors_prime().is_empty()];
assert_eq![Int(7_i128).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<i128>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_i128).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_i128).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(i128, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_i128).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_i128).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_i128).factors_prime_unique_exp().is_empty()];
assert![Int(1_i128).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_i128).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_i128).factors_prime_count(), 4];
assert_eq![Int(-24_i128).factors_prime_count(), 4];
assert_eq![Int(0_i128).factors_prime_count(), 0];
assert_eq![Int(1_i128).factors_prime_count(), 0];
assert_eq![Int(7_i128).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_i128).factors_prime_unique_count(), 2];
assert_eq![Int(-24_i128).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [i128], upfbuf: &mut [i128], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i128).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [i128], upfbuf: &mut [i128], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_i128).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [i128]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_i128).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_i128 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_i128).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_i128).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_i128).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [i128]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_i128).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [i128], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_i128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [i128], upfbuf: &mut [i128], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_i128).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub fn factors(self) -> Vec<isize>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_isize).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![Int(-24_isize).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_isize).factors().is_empty()];
assert_eq![Int(1_isize).factors(), vec![1]];
assert_eq![Int(7_isize).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<isize>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_isize).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert_eq![Int(-24_isize).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_isize).factors_proper().is_empty()];
assert![Int(1_isize).factors_proper().is_empty()];
assert![Int(7_isize).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<isize>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_isize).factors_prime(), vec![2, 2, 2, 3]];
assert_eq![Int(-24_isize).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_isize).factors_prime().is_empty()];
assert![Int(1_isize).factors_prime().is_empty()];
assert_eq![Int(7_isize).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<isize>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_isize).factors_prime_unique(), vec![2, 3]];
assert_eq![Int(-24_isize).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(isize, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_isize).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert_eq![Int(-24_isize).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_isize).factors_prime_unique_exp().is_empty()];
assert![Int(1_isize).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_isize).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_isize).factors_prime_count(), 4];
assert_eq![Int(-24_isize).factors_prime_count(), 4];
assert_eq![Int(0_isize).factors_prime_count(), 0];
assert_eq![Int(1_isize).factors_prime_count(), 0];
assert_eq![Int(7_isize).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_isize).factors_prime_unique_count(), 2];
assert_eq![Int(-24_isize).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [isize], upfbuf: &mut [isize], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_isize).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [isize], upfbuf: &mut [isize], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_isize).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [isize]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_isize).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_isize * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_isize).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_isize).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_isize).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [isize]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_isize).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [isize], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_isize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [isize], upfbuf: &mut [isize], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique prime factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_isize).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub fn factors(self) -> Vec<u8>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_u8).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_u8).factors().is_empty()];
assert_eq![Int(1_u8).factors(), vec![1]];
assert_eq![Int(7_u8).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<u8>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_u8).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_u8).factors_proper().is_empty()];
assert![Int(1_u8).factors_proper().is_empty()];
assert![Int(7_u8).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<u8>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_u8).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_u8).factors_prime().is_empty()];
assert![Int(1_u8).factors_prime().is_empty()];
assert_eq![Int(7_u8).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<u8>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_u8).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(u8, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_u8).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_u8).factors_prime_unique_exp().is_empty()];
assert![Int(1_u8).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_u8).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_u8).factors_prime_count(), 4];
assert_eq![Int(0_u8).factors_prime_count(), 0];
assert_eq![Int(1_u8).factors_prime_count(), 0];
assert_eq![Int(7_u8).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_u8).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [u8], upfbuf: &mut [u8], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u8).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [u8], upfbuf: &mut [u8], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u8).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [u8]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_u8).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_u8 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_u8).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_u8).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_u8).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [u8]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_u8).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [u8], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_u8).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [u8], upfbuf: &mut [u8], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_u8).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub fn factors(self) -> Vec<u16>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_u16).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_u16).factors().is_empty()];
assert_eq![Int(1_u16).factors(), vec![1]];
assert_eq![Int(7_u16).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<u16>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_u16).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_u16).factors_proper().is_empty()];
assert![Int(1_u16).factors_proper().is_empty()];
assert![Int(7_u16).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<u16>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_u16).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_u16).factors_prime().is_empty()];
assert![Int(1_u16).factors_prime().is_empty()];
assert_eq![Int(7_u16).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<u16>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_u16).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(u16, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_u16).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_u16).factors_prime_unique_exp().is_empty()];
assert![Int(1_u16).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_u16).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_u16).factors_prime_count(), 4];
assert_eq![Int(0_u16).factors_prime_count(), 0];
assert_eq![Int(1_u16).factors_prime_count(), 0];
assert_eq![Int(7_u16).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_u16).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [u16], upfbuf: &mut [u16], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u16).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [u16], upfbuf: &mut [u16], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u16).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [u16]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_u16).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_u16 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_u16).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_u16).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_u16).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [u16]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_u16).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [u16], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_u16).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [u16], upfbuf: &mut [u16], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_u16).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub fn factors(self) -> Vec<u32>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_u32).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_u32).factors().is_empty()];
assert_eq![Int(1_u32).factors(), vec![1]];
assert_eq![Int(7_u32).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<u32>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_u32).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_u32).factors_proper().is_empty()];
assert![Int(1_u32).factors_proper().is_empty()];
assert![Int(7_u32).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<u32>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_u32).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_u32).factors_prime().is_empty()];
assert![Int(1_u32).factors_prime().is_empty()];
assert_eq![Int(7_u32).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<u32>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_u32).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(u32, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_u32).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_u32).factors_prime_unique_exp().is_empty()];
assert![Int(1_u32).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_u32).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_u32).factors_prime_count(), 4];
assert_eq![Int(0_u32).factors_prime_count(), 0];
assert_eq![Int(1_u32).factors_prime_count(), 0];
assert_eq![Int(7_u32).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_u32).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [u32], upfbuf: &mut [u32], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u32).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [u32], upfbuf: &mut [u32], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u32).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [u32]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_u32).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_u32 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_u32).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_u32).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_u32).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [u32]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_u32).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [u32], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_u32).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [u32], upfbuf: &mut [u32], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_u32).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub fn factors(self) -> Vec<u64>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_u64).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_u64).factors().is_empty()];
assert_eq![Int(1_u64).factors(), vec![1]];
assert_eq![Int(7_u64).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<u64>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_u64).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_u64).factors_proper().is_empty()];
assert![Int(1_u64).factors_proper().is_empty()];
assert![Int(7_u64).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<u64>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_u64).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_u64).factors_prime().is_empty()];
assert![Int(1_u64).factors_prime().is_empty()];
assert_eq![Int(7_u64).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<u64>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_u64).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(u64, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_u64).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_u64).factors_prime_unique_exp().is_empty()];
assert![Int(1_u64).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_u64).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_u64).factors_prime_count(), 4];
assert_eq![Int(0_u64).factors_prime_count(), 0];
assert_eq![Int(1_u64).factors_prime_count(), 0];
assert_eq![Int(7_u64).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_u64).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [u64], upfbuf: &mut [u64], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u64).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [u64], upfbuf: &mut [u64], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u64).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [u64]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_u64).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_u64 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_u64).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_u64).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_u64).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [u64]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_u64).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [u64], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_u64).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [u64], upfbuf: &mut [u64], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_u64).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub fn factors(self) -> Vec<u128>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_u128).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_u128).factors().is_empty()];
assert_eq![Int(1_u128).factors(), vec![1]];
assert_eq![Int(7_u128).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<u128>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_u128).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_u128).factors_proper().is_empty()];
assert![Int(1_u128).factors_proper().is_empty()];
assert![Int(7_u128).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<u128>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_u128).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_u128).factors_prime().is_empty()];
assert![Int(1_u128).factors_prime().is_empty()];
assert_eq![Int(7_u128).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<u128>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_u128).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(u128, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_u128).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_u128).factors_prime_unique_exp().is_empty()];
assert![Int(1_u128).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_u128).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_u128).factors_prime_count(), 4];
assert_eq![Int(0_u128).factors_prime_count(), 0];
assert_eq![Int(1_u128).factors_prime_count(), 0];
assert_eq![Int(7_u128).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_u128).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [u128], upfbuf: &mut [u128], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u128).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [u128], upfbuf: &mut [u128], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_u128).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [u128]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_u128).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_u128 * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_u128).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_u128).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_u128).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [u128]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_u128).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [u128], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_u128).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [u128], upfbuf: &mut [u128], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_u128).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub fn factors(self) -> Vec<usize>

Available on crate feature alloc only.

Returns the factors (including 1 and self).

§Examples
assert_eq![Int(24_usize).factors(), vec![1, 2, 3, 4, 6, 8, 12, 24]];
assert![Int(0_usize).factors().is_empty()];
assert_eq![Int(1_usize).factors(), vec![1]];
assert_eq![Int(7_usize).factors(), vec![1, 7]];
Source

pub fn factors_proper(self) -> Vec<usize>

Available on crate feature alloc only.

Returns the proper factors.

§Examples
assert_eq![Int(24_usize).factors_proper(), vec![2, 3, 4, 6, 8, 12]];
assert![Int(0_usize).factors_proper().is_empty()];
assert![Int(1_usize).factors_proper().is_empty()];
assert![Int(7_usize).factors_proper().is_empty()];
Source

pub fn factors_prime(self) -> Vec<usize>

Available on crate feature alloc only.

Returns the prime factors.

§Examples
assert_eq![Int(24_usize).factors_prime(), vec![2, 2, 2, 3]];
assert![Int(0_usize).factors_prime().is_empty()];
assert![Int(1_usize).factors_prime().is_empty()];
assert_eq![Int(7_usize).factors_prime(), vec![7]];
Source

pub fn factors_prime_unique(self) -> Vec<usize>

Available on crate feature alloc only.

Returns the unique prime factors.

§Examples
assert_eq![Int(24_usize).factors_prime_unique(), vec![2, 3]];
Source

pub fn factors_prime_unique_exp(self) -> Vec<(usize, u32)>

Available on crate feature alloc only.

Returns the unique prime factors with its exponent.

§Examples
assert_eq![Int(24_usize).factors_prime_unique_exp(), vec![(2, 3), (3, 1)]];
assert![Int(0_usize).factors_prime_unique_exp().is_empty()];
assert![Int(1_usize).factors_prime_unique_exp().is_empty()];
assert_eq![Int(7_usize).factors_prime_unique_exp(), vec![(7, 1)]];
Source

pub fn factors_prime_count(self) -> usize

Returns the count of prime factors.

§Examples
assert_eq![Int(24_usize).factors_prime_count(), 4];
assert_eq![Int(0_usize).factors_prime_count(), 0];
assert_eq![Int(1_usize).factors_prime_count(), 0];
assert_eq![Int(7_usize).factors_prime_count(), 1];
Source

pub fn factors_prime_unique_count(self) -> usize

Returns the count of unique prime factors.

§Examples
assert_eq![Int(24_usize).factors_prime_unique_count(), 2];
Source

pub fn factors_buf( self, fbuf: &mut [usize], upfbuf: &mut [usize], ) -> Result<(usize, usize)>

Writes the factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_usize).factors_buf(&mut fbuf, &mut upbuf), Ok((8, 2))];

assert_eq![fbuf[..8], [1, 2, 3, 4, 6, 8, 12, 24]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_proper_buf( self, fbuf: &mut [usize], upfbuf: &mut [usize], ) -> Result<(usize, usize)>

Writes the proper factors in fbuf, and the unique prime factors in upfbuf.

Returns a tuple with the number of factors and unique prime factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of any buffer.

§Examples
let (mut fbuf, mut upbuf) = ([0; 20], [0; 20]);
assert_eq![Int(24_usize).factors_proper_buf(&mut fbuf, &mut upbuf), Ok((6, 2))];

assert_eq![fbuf[..6], [2, 3, 4, 6, 8, 12,]];
assert_eq![upbuf[..2], [2, 3]];
Source

pub fn factors_prime_buf(self, buffer: &mut [usize]) -> Result<usize>

Writes the prime factors in the given buffer.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let mut buf = [0; 5];
assert_eq![Int(24_usize).factors_prime_buf(&mut buf), Ok(4)];

assert_eq![buf[..4], [2, 2, 2, 3]];
assert![Int(24_usize * 4).factors_prime_buf(&mut buf).is_err()];
assert_eq![buf, [2, 2, 2, 2, 2]]; // the factor of 3 didn't fit

assert_eq![Int(0_usize).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(1_usize).factors_prime_buf(&mut buf), Ok(0)];
assert_eq![Int(7_usize).factors_prime_buf(&mut buf), Ok(1)];
assert_eq![buf[..1], [7]];
Source

pub fn factors_prime_unique_buf(self, buffer: &mut [usize]) -> Result<usize>

Writes the prime factors in the given buffer.

The buffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

§Examples
let mut uniq = [0; 5];
assert_eq![Int(24_usize).factors_prime_unique_buf(&mut uniq), Ok(2)];
assert_eq![uniq, [2, 3, 2, 3, 0]];
Source

pub fn factors_prime_unique_exp_buf( self, fbuffer: &mut [usize], ebuffer: &mut [u32], ) -> Result<usize>

Writes the unique prime factors in the given fbuffer, and the associated exponent in the given ebuffer at the same index.

The fbuffer must be large enough to hold all the non-unique factors of n. In that case the function will return the number of unique factors found.

§Errors

Returns MismatchedSizes otherwise. In that case the buffer will only contain the non-unique factors that could fit, same as factors_prime_buf.

Returns MismatchedSizes if ebuffer is not large enough as well. In that case the number of unique factors will equal ebuffer.len().

§Examples
let mut fbuf = [0; 4];
let mut ebuf = [0; 2];
assert_eq![Int(40_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(2)];
assert_eq![fbuf[..2], [2, 5]]; // 2^3, 5^1, …
assert_eq![ebuf[..2], [3, 1]];

assert_eq![Int(0_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(1_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(0)];
assert_eq![Int(7_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf), Ok(1)];
assert_eq![fbuf[..1], [7]]; // 7^1
assert_eq![ebuf[..1], [1]];

// When `fbuffer` is not large enough:
let mut fbuf = [0; 3];
let mut ebuf = [0; 2];
assert![Int(24_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf, [2, 2, 2]]; // the factor of 5 didn't fit
assert_eq![ebuf, [0, 0]]; // the exponents didn't get written

// When `ebuffer` is not large enough:
let mut fbuf = [0; 4];
let mut ebuf = [0; 1];
assert![Int(24_usize).factors_prime_unique_exp_buf(&mut fbuf, &mut ebuf).is_err()];
assert_eq![fbuf[..ebuf.len()], [2]]; // 2^3, Err, …
assert_eq![ebuf[..], [3]];
Source

pub fn factors_prime_unique_plus_buf( self, pfbuf: &mut [usize], upfbuf: &mut [usize], ) -> Result<(usize, usize)>

Writes the prime factors in pfbuf, and the unique factors in upfbuf.

Returns the number of factors found.

§Errors

Returns MismatchedSizes if the total number of factors is greater than the length of the buffer.

§Examples
let (mut fac, mut uniq) = ([0; 5], [0; 5]);
assert_eq![Int(24_usize).factors_prime_unique_plus_buf(&mut fac, &mut uniq), Ok((4, 2))];
assert_eq![fac, [2, 2, 2, 3, 0]];
assert_eq![uniq, [2, 3, 0, 0, 0]];
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn modulo(self, modulus: i8) -> Result<Int<i8>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i16.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i8).modulo(m)?, 2];
assert_eq![Int(-3_i8).modulo(m)?, 0];
assert_eq![Int(-2_i8).modulo(m)?, 1];
assert_eq![Int(-1_i8).modulo(m)?, 2];
assert_eq![Int( 0_i8).modulo(m)?, 0];
assert_eq![Int( 1_i8).modulo(m)?, 1];
assert_eq![Int( 2_i8).modulo(m)?, 2];
assert_eq![Int( 3_i8).modulo(m)?, 0];
assert_eq![Int( 4_i8).modulo(m)?, 1];

assert_eq![Int(i8::MAX).modulo(i8::MIN)?, i8::MAX];
assert_eq![Int(i8::MIN).modulo(i8::MAX)?, i8::MAX - 1];
assert_eq![Int(i8::MIN).modulo(i8::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_i8).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: i8) -> Int<i8>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i8).modulo_unchecked(m), 2];
assert_eq![Int(-3_i8).modulo_unchecked(m), 0];
assert_eq![Int(-2_i8).modulo_unchecked(m), 1];
assert_eq![Int(-1_i8).modulo_unchecked(m), 2];
assert_eq![Int( 0_i8).modulo_unchecked(m), 0];
assert_eq![Int( 1_i8).modulo_unchecked(m), 1];
assert_eq![Int( 2_i8).modulo_unchecked(m), 2];
assert_eq![Int( 3_i8).modulo_unchecked(m), 0];
assert_eq![Int( 4_i8).modulo_unchecked(m), 1];
assert_eq![Int( 4_i8).modulo_unchecked(-m), 1];

assert_eq![Int(i8::MAX).modulo_unchecked(i8::MAX - 1), 1];
assert_eq![Int(i8::MAX).modulo_unchecked(i8::MAX), 0];
assert_eq![Int(i8::MAX).modulo_unchecked(i8::MIN), i8::MAX];
assert_eq![Int(i8::MIN).modulo_unchecked(i8::MAX), i8::MAX - 1];
assert_eq![Int(i8::MIN).modulo_unchecked(i8::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_i8).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: i8, ) -> Result<ValueQuant<Int<i8>, Int<i8>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i16.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_i8).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_i8).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_i8).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_i8).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_i8).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_i8).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_i8).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: i8, ) -> ValueQuant<Int<i8>, Int<i8>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add(self, other: i8, modulus: i8) -> Result<Int<i8>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_add(-4, m)?, 0];
assert_eq![Int(4_i8).modulo_add(-3, m)?, 1];
assert_eq![Int(4_i8).modulo_add(-2, m)?, 2];
assert_eq![Int(4_i8).modulo_add(-1, m)?, 0];
assert_eq![Int(4_i8).modulo_add( 0, m)?, 1];
assert_eq![Int(4_i8).modulo_add( 1, m)?, 2];
assert_eq![Int(4_i8).modulo_add( 2, m)?, 0];
assert_eq![Int(4_i8).modulo_add( 3, m)?, 1];
assert_eq![Int(4_i8).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: i8, modulus: i8) -> Int<i8>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: i8, modulus: i8, ) -> Result<ValueQuant<Int<i8>, Int<i8>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_i8).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_i8).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_i8).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_i8).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i8).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_i8).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_i8).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_i8).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: i8, modulus: i8, ) -> ValueQuant<Int<i8>, Int<i8>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: i8) -> Result<Int<i8>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_i8).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_i8).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_i8).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_i8).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_i8).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_i8).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_i8).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_i8).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: i8) -> Int<i8>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: i8, modulus: i8) -> Result<Int<i8>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_i8).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_i8).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_i8).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_i8).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_i8).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_i8).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_i8).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_i8).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: i8, modulus: i8) -> Int<i8>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: i8, modulus: i8, ) -> Result<ValueQuant<Int<i8>, Int<i8>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_i8).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_i8).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_i8).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i8).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i8).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_i8).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_i8).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_i8).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: i8, modulus: i8, ) -> (Int<i8>, Int<i8>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul(self, other: i8, modulus: i8) -> Result<Int<i8>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_i8).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_i8).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_i8).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_i8).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_i8).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_i8).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_i8).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_i8).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: i8, modulus: i8) -> Int<i8>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: i8, modulus: i8, ) -> Result<ValueQuant<Int<i8>, Int<i8>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i8).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_i8).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_i8).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_i8).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i8).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_i8).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_i8).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_i8).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_i8).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: i8, modulus: i8, ) -> ValueQuant<Int<i8>, Int<i8>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: i8) -> Result<Int<i8>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_i8).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_i8).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_i8).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_i8).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_i8).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_i8).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_i8).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_i8).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_i8).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: i8) -> Int<i8>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div(self, other: i8, modulus: i8) -> Result<Int<i8>>

Computes self / other over |modulus|.

Performs operations internally as i16.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_i8).modulo_div(2, m)?, 1];
assert_eq![Int(-3_i8).modulo_div(2, m)?, 0];
assert_eq![Int(-2_i8).modulo_div(2, m)?, 2];
assert_eq![Int(-1_i8).modulo_div(2, m)?, 1];
assert_eq![Int( 0_i8).modulo_div(2, m)?, 0];
assert_eq![Int( 1_i8).modulo_div(2, m)?, 2];
assert_eq![Int( 2_i8).modulo_div(2, m)?, 1];
assert_eq![Int( 3_i8).modulo_div(2, m)?, 0];
assert_eq![Int( 4_i8).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: i8, modulus: i8) -> Int<i8>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn modulo(self, modulus: i16) -> Result<Int<i16>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i32.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i16).modulo(m)?, 2];
assert_eq![Int(-3_i16).modulo(m)?, 0];
assert_eq![Int(-2_i16).modulo(m)?, 1];
assert_eq![Int(-1_i16).modulo(m)?, 2];
assert_eq![Int( 0_i16).modulo(m)?, 0];
assert_eq![Int( 1_i16).modulo(m)?, 1];
assert_eq![Int( 2_i16).modulo(m)?, 2];
assert_eq![Int( 3_i16).modulo(m)?, 0];
assert_eq![Int( 4_i16).modulo(m)?, 1];

assert_eq![Int(i16::MAX).modulo(i16::MIN)?, i16::MAX];
assert_eq![Int(i16::MIN).modulo(i16::MAX)?, i16::MAX - 1];
assert_eq![Int(i16::MIN).modulo(i16::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_i16).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: i16) -> Int<i16>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i16).modulo_unchecked(m), 2];
assert_eq![Int(-3_i16).modulo_unchecked(m), 0];
assert_eq![Int(-2_i16).modulo_unchecked(m), 1];
assert_eq![Int(-1_i16).modulo_unchecked(m), 2];
assert_eq![Int( 0_i16).modulo_unchecked(m), 0];
assert_eq![Int( 1_i16).modulo_unchecked(m), 1];
assert_eq![Int( 2_i16).modulo_unchecked(m), 2];
assert_eq![Int( 3_i16).modulo_unchecked(m), 0];
assert_eq![Int( 4_i16).modulo_unchecked(m), 1];
assert_eq![Int( 4_i16).modulo_unchecked(-m), 1];

assert_eq![Int(i16::MAX).modulo_unchecked(i16::MAX - 1), 1];
assert_eq![Int(i16::MAX).modulo_unchecked(i16::MAX), 0];
assert_eq![Int(i16::MAX).modulo_unchecked(i16::MIN), i16::MAX];
assert_eq![Int(i16::MIN).modulo_unchecked(i16::MAX), i16::MAX - 1];
assert_eq![Int(i16::MIN).modulo_unchecked(i16::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_i16).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: i16, ) -> Result<ValueQuant<Int<i16>, Int<i16>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i32.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_i16).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_i16).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_i16).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_i16).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_i16).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_i16).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_i16).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: i16, ) -> ValueQuant<Int<i16>, Int<i16>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add(self, other: i16, modulus: i16) -> Result<Int<i16>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_add(-4, m)?, 0];
assert_eq![Int(4_i16).modulo_add(-3, m)?, 1];
assert_eq![Int(4_i16).modulo_add(-2, m)?, 2];
assert_eq![Int(4_i16).modulo_add(-1, m)?, 0];
assert_eq![Int(4_i16).modulo_add( 0, m)?, 1];
assert_eq![Int(4_i16).modulo_add( 1, m)?, 2];
assert_eq![Int(4_i16).modulo_add( 2, m)?, 0];
assert_eq![Int(4_i16).modulo_add( 3, m)?, 1];
assert_eq![Int(4_i16).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: i16, modulus: i16) -> Int<i16>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: i16, modulus: i16, ) -> Result<ValueQuant<Int<i16>, Int<i16>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_i16).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_i16).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_i16).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_i16).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i16).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_i16).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_i16).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_i16).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: i16, modulus: i16, ) -> ValueQuant<Int<i16>, Int<i16>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: i16) -> Result<Int<i16>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_i16).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_i16).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_i16).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_i16).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_i16).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_i16).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_i16).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_i16).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: i16) -> Int<i16>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: i16, modulus: i16) -> Result<Int<i16>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_i16).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_i16).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_i16).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_i16).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_i16).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_i16).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_i16).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_i16).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: i16, modulus: i16) -> Int<i16>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: i16, modulus: i16, ) -> Result<ValueQuant<Int<i16>, Int<i16>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_i16).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_i16).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_i16).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i16).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i16).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_i16).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_i16).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_i16).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: i16, modulus: i16, ) -> (Int<i16>, Int<i16>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul(self, other: i16, modulus: i16) -> Result<Int<i16>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_i16).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_i16).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_i16).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_i16).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_i16).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_i16).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_i16).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_i16).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: i16, modulus: i16) -> Int<i16>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: i16, modulus: i16, ) -> Result<ValueQuant<Int<i16>, Int<i16>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i16).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_i16).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_i16).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_i16).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i16).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_i16).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_i16).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_i16).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_i16).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: i16, modulus: i16, ) -> ValueQuant<Int<i16>, Int<i16>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: i16) -> Result<Int<i16>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_i16).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_i16).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_i16).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_i16).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_i16).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_i16).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_i16).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_i16).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_i16).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: i16) -> Int<i16>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div(self, other: i16, modulus: i16) -> Result<Int<i16>>

Computes self / other over |modulus|.

Performs operations internally as i32.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_i16).modulo_div(2, m)?, 1];
assert_eq![Int(-3_i16).modulo_div(2, m)?, 0];
assert_eq![Int(-2_i16).modulo_div(2, m)?, 2];
assert_eq![Int(-1_i16).modulo_div(2, m)?, 1];
assert_eq![Int( 0_i16).modulo_div(2, m)?, 0];
assert_eq![Int( 1_i16).modulo_div(2, m)?, 2];
assert_eq![Int( 2_i16).modulo_div(2, m)?, 1];
assert_eq![Int( 3_i16).modulo_div(2, m)?, 0];
assert_eq![Int( 4_i16).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: i16, modulus: i16) -> Int<i16>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn modulo(self, modulus: i32) -> Result<Int<i32>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i64.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i32).modulo(m)?, 2];
assert_eq![Int(-3_i32).modulo(m)?, 0];
assert_eq![Int(-2_i32).modulo(m)?, 1];
assert_eq![Int(-1_i32).modulo(m)?, 2];
assert_eq![Int( 0_i32).modulo(m)?, 0];
assert_eq![Int( 1_i32).modulo(m)?, 1];
assert_eq![Int( 2_i32).modulo(m)?, 2];
assert_eq![Int( 3_i32).modulo(m)?, 0];
assert_eq![Int( 4_i32).modulo(m)?, 1];

assert_eq![Int(i32::MAX).modulo(i32::MIN)?, i32::MAX];
assert_eq![Int(i32::MIN).modulo(i32::MAX)?, i32::MAX - 1];
assert_eq![Int(i32::MIN).modulo(i32::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_i32).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: i32) -> Int<i32>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i32).modulo_unchecked(m), 2];
assert_eq![Int(-3_i32).modulo_unchecked(m), 0];
assert_eq![Int(-2_i32).modulo_unchecked(m), 1];
assert_eq![Int(-1_i32).modulo_unchecked(m), 2];
assert_eq![Int( 0_i32).modulo_unchecked(m), 0];
assert_eq![Int( 1_i32).modulo_unchecked(m), 1];
assert_eq![Int( 2_i32).modulo_unchecked(m), 2];
assert_eq![Int( 3_i32).modulo_unchecked(m), 0];
assert_eq![Int( 4_i32).modulo_unchecked(m), 1];
assert_eq![Int( 4_i32).modulo_unchecked(-m), 1];

assert_eq![Int(i32::MAX).modulo_unchecked(i32::MAX - 1), 1];
assert_eq![Int(i32::MAX).modulo_unchecked(i32::MAX), 0];
assert_eq![Int(i32::MAX).modulo_unchecked(i32::MIN), i32::MAX];
assert_eq![Int(i32::MIN).modulo_unchecked(i32::MAX), i32::MAX - 1];
assert_eq![Int(i32::MIN).modulo_unchecked(i32::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_i32).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: i32, ) -> Result<ValueQuant<Int<i32>, Int<i32>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i64.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_i32).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_i32).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_i32).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_i32).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_i32).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_i32).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_i32).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: i32, ) -> ValueQuant<Int<i32>, Int<i32>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add(self, other: i32, modulus: i32) -> Result<Int<i32>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_add(-4, m)?, 0];
assert_eq![Int(4_i32).modulo_add(-3, m)?, 1];
assert_eq![Int(4_i32).modulo_add(-2, m)?, 2];
assert_eq![Int(4_i32).modulo_add(-1, m)?, 0];
assert_eq![Int(4_i32).modulo_add( 0, m)?, 1];
assert_eq![Int(4_i32).modulo_add( 1, m)?, 2];
assert_eq![Int(4_i32).modulo_add( 2, m)?, 0];
assert_eq![Int(4_i32).modulo_add( 3, m)?, 1];
assert_eq![Int(4_i32).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: i32, modulus: i32) -> Int<i32>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: i32, modulus: i32, ) -> Result<ValueQuant<Int<i32>, Int<i32>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_i32).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_i32).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_i32).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_i32).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i32).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_i32).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_i32).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_i32).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: i32, modulus: i32, ) -> ValueQuant<Int<i32>, Int<i32>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: i32) -> Result<Int<i32>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_i32).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_i32).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_i32).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_i32).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_i32).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_i32).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_i32).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_i32).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: i32) -> Int<i32>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: i32, modulus: i32) -> Result<Int<i32>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_i32).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_i32).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_i32).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_i32).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_i32).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_i32).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_i32).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_i32).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: i32, modulus: i32) -> Int<i32>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: i32, modulus: i32, ) -> Result<ValueQuant<Int<i32>, Int<i32>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_i32).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_i32).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_i32).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i32).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i32).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_i32).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_i32).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_i32).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: i32, modulus: i32, ) -> (Int<i32>, Int<i32>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul(self, other: i32, modulus: i32) -> Result<Int<i32>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_i32).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_i32).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_i32).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_i32).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_i32).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_i32).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_i32).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_i32).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: i32, modulus: i32) -> Int<i32>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: i32, modulus: i32, ) -> Result<ValueQuant<Int<i32>, Int<i32>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i32).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_i32).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_i32).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_i32).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i32).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_i32).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_i32).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_i32).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_i32).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: i32, modulus: i32, ) -> ValueQuant<Int<i32>, Int<i32>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: i32) -> Result<Int<i32>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_i32).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_i32).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_i32).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_i32).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_i32).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_i32).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_i32).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_i32).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_i32).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: i32) -> Int<i32>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div(self, other: i32, modulus: i32) -> Result<Int<i32>>

Computes self / other over |modulus|.

Performs operations internally as i64.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_i32).modulo_div(2, m)?, 1];
assert_eq![Int(-3_i32).modulo_div(2, m)?, 0];
assert_eq![Int(-2_i32).modulo_div(2, m)?, 2];
assert_eq![Int(-1_i32).modulo_div(2, m)?, 1];
assert_eq![Int( 0_i32).modulo_div(2, m)?, 0];
assert_eq![Int( 1_i32).modulo_div(2, m)?, 2];
assert_eq![Int( 2_i32).modulo_div(2, m)?, 1];
assert_eq![Int( 3_i32).modulo_div(2, m)?, 0];
assert_eq![Int( 4_i32).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: i32, modulus: i32) -> Int<i32>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn modulo(self, modulus: i64) -> Result<Int<i64>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i128.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i64).modulo(m)?, 2];
assert_eq![Int(-3_i64).modulo(m)?, 0];
assert_eq![Int(-2_i64).modulo(m)?, 1];
assert_eq![Int(-1_i64).modulo(m)?, 2];
assert_eq![Int( 0_i64).modulo(m)?, 0];
assert_eq![Int( 1_i64).modulo(m)?, 1];
assert_eq![Int( 2_i64).modulo(m)?, 2];
assert_eq![Int( 3_i64).modulo(m)?, 0];
assert_eq![Int( 4_i64).modulo(m)?, 1];

assert_eq![Int(i64::MAX).modulo(i64::MIN)?, i64::MAX];
assert_eq![Int(i64::MIN).modulo(i64::MAX)?, i64::MAX - 1];
assert_eq![Int(i64::MIN).modulo(i64::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_i64).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: i64) -> Int<i64>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i64).modulo_unchecked(m), 2];
assert_eq![Int(-3_i64).modulo_unchecked(m), 0];
assert_eq![Int(-2_i64).modulo_unchecked(m), 1];
assert_eq![Int(-1_i64).modulo_unchecked(m), 2];
assert_eq![Int( 0_i64).modulo_unchecked(m), 0];
assert_eq![Int( 1_i64).modulo_unchecked(m), 1];
assert_eq![Int( 2_i64).modulo_unchecked(m), 2];
assert_eq![Int( 3_i64).modulo_unchecked(m), 0];
assert_eq![Int( 4_i64).modulo_unchecked(m), 1];
assert_eq![Int( 4_i64).modulo_unchecked(-m), 1];

assert_eq![Int(i64::MAX).modulo_unchecked(i64::MAX - 1), 1];
assert_eq![Int(i64::MAX).modulo_unchecked(i64::MAX), 0];
assert_eq![Int(i64::MAX).modulo_unchecked(i64::MIN), i64::MAX];
assert_eq![Int(i64::MIN).modulo_unchecked(i64::MAX), i64::MAX - 1];
assert_eq![Int(i64::MIN).modulo_unchecked(i64::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_i64).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: i64, ) -> Result<ValueQuant<Int<i64>, Int<i64>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_i64).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_i64).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_i64).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_i64).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_i64).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_i64).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_i64).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: i64, ) -> ValueQuant<Int<i64>, Int<i64>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add(self, other: i64, modulus: i64) -> Result<Int<i64>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_add(-4, m)?, 0];
assert_eq![Int(4_i64).modulo_add(-3, m)?, 1];
assert_eq![Int(4_i64).modulo_add(-2, m)?, 2];
assert_eq![Int(4_i64).modulo_add(-1, m)?, 0];
assert_eq![Int(4_i64).modulo_add( 0, m)?, 1];
assert_eq![Int(4_i64).modulo_add( 1, m)?, 2];
assert_eq![Int(4_i64).modulo_add( 2, m)?, 0];
assert_eq![Int(4_i64).modulo_add( 3, m)?, 1];
assert_eq![Int(4_i64).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: i64, modulus: i64) -> Int<i64>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: i64, modulus: i64, ) -> Result<ValueQuant<Int<i64>, Int<i64>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_i64).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_i64).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_i64).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_i64).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i64).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_i64).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_i64).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_i64).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: i64, modulus: i64, ) -> ValueQuant<Int<i64>, Int<i64>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: i64) -> Result<Int<i64>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_i64).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_i64).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_i64).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_i64).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_i64).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_i64).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_i64).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_i64).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: i64) -> Int<i64>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: i64, modulus: i64) -> Result<Int<i64>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_i64).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_i64).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_i64).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_i64).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_i64).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_i64).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_i64).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_i64).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: i64, modulus: i64) -> Int<i64>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: i64, modulus: i64, ) -> Result<ValueQuant<Int<i64>, Int<i64>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_i64).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_i64).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_i64).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i64).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i64).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_i64).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_i64).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_i64).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: i64, modulus: i64, ) -> (Int<i64>, Int<i64>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul(self, other: i64, modulus: i64) -> Result<Int<i64>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_i64).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_i64).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_i64).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_i64).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_i64).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_i64).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_i64).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_i64).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: i64, modulus: i64) -> Int<i64>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: i64, modulus: i64, ) -> Result<ValueQuant<Int<i64>, Int<i64>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i64).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_i64).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_i64).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_i64).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i64).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_i64).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_i64).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_i64).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_i64).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: i64, modulus: i64, ) -> ValueQuant<Int<i64>, Int<i64>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: i64) -> Result<Int<i64>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_i64).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_i64).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_i64).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_i64).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_i64).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_i64).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_i64).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_i64).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_i64).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: i64) -> Int<i64>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div(self, other: i64, modulus: i64) -> Result<Int<i64>>

Computes self / other over |modulus|.

Performs operations internally as i128.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_i64).modulo_div(2, m)?, 1];
assert_eq![Int(-3_i64).modulo_div(2, m)?, 0];
assert_eq![Int(-2_i64).modulo_div(2, m)?, 2];
assert_eq![Int(-1_i64).modulo_div(2, m)?, 1];
assert_eq![Int( 0_i64).modulo_div(2, m)?, 0];
assert_eq![Int( 1_i64).modulo_div(2, m)?, 2];
assert_eq![Int( 2_i64).modulo_div(2, m)?, 1];
assert_eq![Int( 3_i64).modulo_div(2, m)?, 0];
assert_eq![Int( 4_i64).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: i64, modulus: i64) -> Int<i64>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn modulo(self, modulus: i128) -> Result<Int<i128>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i128.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i128).modulo(m)?, 2];
assert_eq![Int(-3_i128).modulo(m)?, 0];
assert_eq![Int(-2_i128).modulo(m)?, 1];
assert_eq![Int(-1_i128).modulo(m)?, 2];
assert_eq![Int( 0_i128).modulo(m)?, 0];
assert_eq![Int( 1_i128).modulo(m)?, 1];
assert_eq![Int( 2_i128).modulo(m)?, 2];
assert_eq![Int( 3_i128).modulo(m)?, 0];
assert_eq![Int( 4_i128).modulo(m)?, 1];

assert_eq![Int(i128::MAX).modulo(i128::MIN)?, i128::MAX];
assert_eq![Int(i128::MIN).modulo(i128::MAX)?, i128::MAX - 1];
assert_eq![Int(i128::MIN).modulo(i128::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_i128).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: i128) -> Int<i128>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_i128).modulo_unchecked(m), 2];
assert_eq![Int(-3_i128).modulo_unchecked(m), 0];
assert_eq![Int(-2_i128).modulo_unchecked(m), 1];
assert_eq![Int(-1_i128).modulo_unchecked(m), 2];
assert_eq![Int( 0_i128).modulo_unchecked(m), 0];
assert_eq![Int( 1_i128).modulo_unchecked(m), 1];
assert_eq![Int( 2_i128).modulo_unchecked(m), 2];
assert_eq![Int( 3_i128).modulo_unchecked(m), 0];
assert_eq![Int( 4_i128).modulo_unchecked(m), 1];
assert_eq![Int( 4_i128).modulo_unchecked(-m), 1];

assert_eq![Int(i128::MAX).modulo_unchecked(i128::MAX - 1), 1];
assert_eq![Int(i128::MAX).modulo_unchecked(i128::MAX), 0];
assert_eq![Int(i128::MAX).modulo_unchecked(i128::MIN), i128::MAX];
assert_eq![Int(i128::MIN).modulo_unchecked(i128::MAX), i128::MAX - 1];
assert_eq![Int(i128::MIN).modulo_unchecked(i128::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_i128).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: i128, ) -> Result<ValueQuant<Int<i128>, Int<i128>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_i128).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_i128).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_i128).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_i128).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_i128).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_i128).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_i128).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: i128, ) -> ValueQuant<Int<i128>, Int<i128>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add(self, other: i128, modulus: i128) -> Result<Int<i128>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_add(-4, m)?, 0];
assert_eq![Int(4_i128).modulo_add(-3, m)?, 1];
assert_eq![Int(4_i128).modulo_add(-2, m)?, 2];
assert_eq![Int(4_i128).modulo_add(-1, m)?, 0];
assert_eq![Int(4_i128).modulo_add( 0, m)?, 1];
assert_eq![Int(4_i128).modulo_add( 1, m)?, 2];
assert_eq![Int(4_i128).modulo_add( 2, m)?, 0];
assert_eq![Int(4_i128).modulo_add( 3, m)?, 1];
assert_eq![Int(4_i128).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: i128, modulus: i128) -> Int<i128>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: i128, modulus: i128, ) -> Result<ValueQuant<Int<i128>, Int<i128>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_i128).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_i128).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_i128).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_i128).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i128).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_i128).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_i128).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_i128).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: i128, modulus: i128, ) -> ValueQuant<Int<i128>, Int<i128>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: i128) -> Result<Int<i128>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_i128).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_i128).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_i128).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_i128).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_i128).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_i128).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_i128).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_i128).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: i128) -> Int<i128>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: i128, modulus: i128) -> Result<Int<i128>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_i128).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_i128).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_i128).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_i128).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_i128).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_i128).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_i128).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_i128).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: i128, modulus: i128) -> Int<i128>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: i128, modulus: i128, ) -> Result<ValueQuant<Int<i128>, Int<i128>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_i128).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_i128).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_i128).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i128).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_i128).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_i128).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_i128).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_i128).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: i128, modulus: i128, ) -> (Int<i128>, Int<i128>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul(self, other: i128, modulus: i128) -> Result<Int<i128>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_i128).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_i128).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_i128).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_i128).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_i128).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_i128).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_i128).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_i128).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: i128, modulus: i128) -> Int<i128>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: i128, modulus: i128, ) -> Result<ValueQuant<Int<i128>, Int<i128>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_i128).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_i128).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_i128).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_i128).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_i128).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_i128).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_i128).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_i128).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_i128).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: i128, modulus: i128, ) -> ValueQuant<Int<i128>, Int<i128>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: i128) -> Result<Int<i128>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_i128).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_i128).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_i128).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_i128).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_i128).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_i128).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_i128).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_i128).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_i128).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: i128) -> Int<i128>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div(self, other: i128, modulus: i128) -> Result<Int<i128>>

Computes self / other over |modulus|.

Performs operations internally as i128.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_i128).modulo_div(2, m)?, 1];
assert_eq![Int(-3_i128).modulo_div(2, m)?, 0];
assert_eq![Int(-2_i128).modulo_div(2, m)?, 2];
assert_eq![Int(-1_i128).modulo_div(2, m)?, 1];
assert_eq![Int( 0_i128).modulo_div(2, m)?, 0];
assert_eq![Int( 1_i128).modulo_div(2, m)?, 2];
assert_eq![Int( 2_i128).modulo_div(2, m)?, 1];
assert_eq![Int( 3_i128).modulo_div(2, m)?, 0];
assert_eq![Int( 4_i128).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: i128, modulus: i128) -> Int<i128>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn modulo(self, modulus: isize) -> Result<Int<isize>>

Computes the non-negative modulo of self over |modulus|.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as isize_up.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(-4_isize).modulo(m)?, 2];
assert_eq![Int(-3_isize).modulo(m)?, 0];
assert_eq![Int(-2_isize).modulo(m)?, 1];
assert_eq![Int(-1_isize).modulo(m)?, 2];
assert_eq![Int( 0_isize).modulo(m)?, 0];
assert_eq![Int( 1_isize).modulo(m)?, 1];
assert_eq![Int( 2_isize).modulo(m)?, 2];
assert_eq![Int( 3_isize).modulo(m)?, 0];
assert_eq![Int( 4_isize).modulo(m)?, 1];

assert_eq![Int(isize::MAX).modulo(isize::MIN)?, isize::MAX];
assert_eq![Int(isize::MIN).modulo(isize::MAX)?, isize::MAX - 1];
assert_eq![Int(isize::MIN).modulo(isize::MIN)?, 0];
assert![Int(i64::MIN).modulo(-1).is_ok()];

assert_eq![Int(1_isize).modulo(0), Err(NumError::NonZeroRequired)];
assert_eq![Int(i128::MIN).modulo(-1), Err(NumError::Overflow(None))];
Source

pub const fn modulo_unchecked(self, modulus: isize) -> Int<isize>

Computes the non-negative modulo of self over |modulus|, unchecked version.

The result is non-negative and less than the absolute value of modulus, i.e., in the range $ [0, |\text{modulus}|) $.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

§Examples
let m = 3;
assert_eq![Int(-4_isize).modulo_unchecked(m), 2];
assert_eq![Int(-3_isize).modulo_unchecked(m), 0];
assert_eq![Int(-2_isize).modulo_unchecked(m), 1];
assert_eq![Int(-1_isize).modulo_unchecked(m), 2];
assert_eq![Int( 0_isize).modulo_unchecked(m), 0];
assert_eq![Int( 1_isize).modulo_unchecked(m), 1];
assert_eq![Int( 2_isize).modulo_unchecked(m), 2];
assert_eq![Int( 3_isize).modulo_unchecked(m), 0];
assert_eq![Int( 4_isize).modulo_unchecked(m), 1];
assert_eq![Int( 4_isize).modulo_unchecked(-m), 1];

assert_eq![Int(isize::MAX).modulo_unchecked(isize::MAX - 1), 1];
assert_eq![Int(isize::MAX).modulo_unchecked(isize::MAX), 0];
assert_eq![Int(isize::MAX).modulo_unchecked(isize::MIN), isize::MAX];
assert_eq![Int(isize::MIN).modulo_unchecked(isize::MAX), isize::MAX - 1];
assert_eq![Int(isize::MIN).modulo_unchecked(isize::MIN), 0];

assert_eq![Int(i64::MIN).modulo_unchecked(-1), 0];
let _ = Int(i128::MIN).modulo_unchecked(-1); // i128 could overflow
let _ = Int(1_isize).modulo_unchecked(0); // panics if modulus == 0
Source

pub const fn modulo_cycles( self, modulus: isize, ) -> Result<ValueQuant<Int<isize>, Int<isize>>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as isize_up.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 if self == MIN && modulus == ±1 it can return Overflow.

§Examples
let m = 3;
assert_eq![Int(-3_isize).modulo_cycles(m)?, (0, 1)];
assert_eq![Int(-2_isize).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(-1_isize).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 0_isize).modulo_cycles(m)?, (0, 0)];
assert_eq![Int( 1_isize).modulo_cycles(m)?, (1, 0)];
assert_eq![Int( 2_isize).modulo_cycles(m)?, (2, 0)];
assert_eq![Int( 3_isize).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: isize, ) -> ValueQuant<Int<isize>, Int<isize>>

Computes the non-negative modulo of self over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, and for i128 it can also panic if self == MIN && modulus == ±1.

Source

pub const fn modulo_add( self, other: isize, modulus: isize, ) -> Result<Int<isize>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_add(-4, m)?, 0];
assert_eq![Int(4_isize).modulo_add(-3, m)?, 1];
assert_eq![Int(4_isize).modulo_add(-2, m)?, 2];
assert_eq![Int(4_isize).modulo_add(-1, m)?, 0];
assert_eq![Int(4_isize).modulo_add( 0, m)?, 1];
assert_eq![Int(4_isize).modulo_add( 1, m)?, 2];
assert_eq![Int(4_isize).modulo_add( 2, m)?, 0];
assert_eq![Int(4_isize).modulo_add( 3, m)?, 1];
assert_eq![Int(4_isize).modulo_add( 4, m)?, 2];
Source

pub const fn modulo_add_unchecked( self, other: isize, modulus: isize, ) -> Int<isize>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: isize, modulus: isize, ) -> Result<ValueQuant<Int<isize>, Int<isize>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_add_cycles(-4, m)?, (0, 0)];
assert_eq![Int(4_isize).modulo_add_cycles(-3, m)?, (1, 0)];
assert_eq![Int(4_isize).modulo_add_cycles(-2, m)?, (2, 0)];
assert_eq![Int(4_isize).modulo_add_cycles(-1, m)?, (0, 1)];
assert_eq![Int(4_isize).modulo_add_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_isize).modulo_add_cycles( 1, m)?, (2, 1)];
assert_eq![Int(4_isize).modulo_add_cycles( 2, m)?, (0, 2)];
assert_eq![Int(4_isize).modulo_add_cycles( 3, m)?, (1, 2)];
assert_eq![Int(4_isize).modulo_add_cycles( 4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: isize, modulus: isize, ) -> ValueQuant<Int<isize>, Int<isize>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: isize) -> Result<Int<isize>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(-4_isize).modulo_add_inv(m)?, 1];
assert_eq![Int(-3_isize).modulo_add_inv(m)?, 0];
assert_eq![Int(-2_isize).modulo_add_inv(m)?, 2];
assert_eq![Int(-1_isize).modulo_add_inv(m)?, 1];
assert_eq![Int( 0_isize).modulo_add_inv(m)?, 0];
assert_eq![Int( 1_isize).modulo_add_inv(m)?, 2];
assert_eq![Int( 2_isize).modulo_add_inv(m)?, 1];
assert_eq![Int( 3_isize).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: isize) -> Int<isize>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub( self, other: isize, modulus: isize, ) -> Result<Int<isize>>

Computes the modulo of self - other over |modulus|.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_sub(-4, m)?, 2];
assert_eq![Int(4_isize).modulo_sub(-3, m)?, 1];
assert_eq![Int(4_isize).modulo_sub(-2, m)?, 0];
assert_eq![Int(4_isize).modulo_sub(-1, m)?, 2];
assert_eq![Int(4_isize).modulo_sub( 0, m)?, 1];
assert_eq![Int(4_isize).modulo_sub( 1, m)?, 0];
assert_eq![Int(4_isize).modulo_sub( 2, m)?, 2];
assert_eq![Int(4_isize).modulo_sub( 3, m)?, 1];
assert_eq![Int(4_isize).modulo_sub( 4, m)?, 0];
Source

pub const fn modulo_sub_unchecked( self, other: isize, modulus: isize, ) -> Int<isize>

Computes the modulo of self - other over |modulus|, unchecked version.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub_cycles( self, other: isize, modulus: isize, ) -> Result<ValueQuant<Int<isize>, Int<isize>>>

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow (unlike modulo_sub) since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_sub_cycles(-4, m)?, (2, 2)];
assert_eq![Int(4_isize).modulo_sub_cycles(-3, m)?, (1, 2)];
assert_eq![Int(4_isize).modulo_sub_cycles(-2, m)?, (0, 2)];
assert_eq![Int(4_isize).modulo_sub_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_isize).modulo_sub_cycles( 0, m)?, (1, 1)];
assert_eq![Int(4_isize).modulo_sub_cycles( 1, m)?, (0, 1)];
assert_eq![Int(4_isize).modulo_sub_cycles( 2, m)?, (2, 0)];
assert_eq![Int(4_isize).modulo_sub_cycles( 3, m)?, (1, 0)];
assert_eq![Int(4_isize).modulo_sub_cycles( 4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: isize, modulus: isize, ) -> (Int<isize>, Int<isize>)

Computes the non-negative modulo of self - other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_sub_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul( self, other: isize, modulus: isize, ) -> Result<Int<isize>>

Computes the non-negative modulo of self + other over |modulus|.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_mul(-4, m)?, 2];
assert_eq![Int(4_isize).modulo_mul(-3, m)?, 0];
assert_eq![Int(4_isize).modulo_mul(-2, m)?, 1];
assert_eq![Int(4_isize).modulo_mul(-1, m)?, 2];
assert_eq![Int(4_isize).modulo_mul( 0, m)?, 0];
assert_eq![Int(4_isize).modulo_mul( 1, m)?, 1];
assert_eq![Int(4_isize).modulo_mul( 2, m)?, 2];
assert_eq![Int(4_isize).modulo_mul( 3, m)?, 0];
assert_eq![Int(4_isize).modulo_mul( 4, m)?, 1];
Source

pub const fn modulo_mul_unchecked( self, other: isize, modulus: isize, ) -> Int<isize>

Computes the non-negative modulo of self + other over |modulus|, unchecked version.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for i128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: isize, modulus: isize, ) -> Result<ValueQuant<Int<isize>, Int<isize>>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for i128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_isize).modulo_mul_cycles(-4, m)?, (2, 5)];
assert_eq![Int(4_isize).modulo_mul_cycles(-3, m)?, (0, 4)];
assert_eq![Int(4_isize).modulo_mul_cycles(-2, m)?, (1, 2)];
assert_eq![Int(4_isize).modulo_mul_cycles(-1, m)?, (2, 1)];
assert_eq![Int(4_isize).modulo_mul_cycles( 0, m)?, (0, 0)];
assert_eq![Int(4_isize).modulo_mul_cycles( 1, m)?, (1, 1)];
assert_eq![Int(4_isize).modulo_mul_cycles( 2, m)?, (2, 2)];
assert_eq![Int(4_isize).modulo_mul_cycles( 3, m)?, (0, 4)];
assert_eq![Int(4_isize).modulo_mul_cycles( 4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: isize, modulus: isize, ) -> ValueQuant<Int<isize>, Int<isize>>

Computes the non-negative modulo of self + other over |modulus|, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, and for i128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: isize) -> Result<Int<isize>>

Calculates the modular multiplicative inverse.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, or NoInverse if there’s no inverse.

§Examples
let m = 5;
assert_eq![Int(-4_isize).modulo_mul_inv(m)?, 4];
assert_eq![Int(-3_isize).modulo_mul_inv(m)?, 2];
assert_eq![Int(-2_isize).modulo_mul_inv(m)?, 3];
assert_eq![Int(-1_isize).modulo_mul_inv(m)?, 1];
assert_eq![Int( 0_isize).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int( 1_isize).modulo_mul_inv(m)?, 1];
assert_eq![Int( 2_isize).modulo_mul_inv(m)?, 3];
assert_eq![Int( 3_isize).modulo_mul_inv(m)?, 2];
assert_eq![Int( 4_isize).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: isize) -> Int<isize>

Calculates the modular multiplicative inverse, unchecked version.

The modular multiplicative inverse of self modulo modulus is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, and if there’s no inverse.

Source

pub const fn modulo_div( self, other: isize, modulus: isize, ) -> Result<Int<isize>>

Computes self / other over |modulus|.

Performs operations internally as isize_up.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, and NoInverse if there’s no multiplicative inverse of other.

§Examples
let m = 3;
assert_eq![Int(-4_isize).modulo_div(2, m)?, 1];
assert_eq![Int(-3_isize).modulo_div(2, m)?, 0];
assert_eq![Int(-2_isize).modulo_div(2, m)?, 2];
assert_eq![Int(-1_isize).modulo_div(2, m)?, 1];
assert_eq![Int( 0_isize).modulo_div(2, m)?, 0];
assert_eq![Int( 1_isize).modulo_div(2, m)?, 2];
assert_eq![Int( 2_isize).modulo_div(2, m)?, 1];
assert_eq![Int( 3_isize).modulo_div(2, m)?, 0];
assert_eq![Int( 4_isize).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked( self, other: isize, modulus: isize, ) -> Int<isize>

Computes self / other over |modulus|, unchecked version.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, and if there’s no multiplicative inverse of other.

Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn modulo(self, modulus: u8) -> Result<Int<u8>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo(m)?, 0];
assert_eq![Int(1_u8).modulo(m)?, 1];
assert_eq![Int(2_u8).modulo(m)?, 2];
assert_eq![Int(3_u8).modulo(m)?, 0];
assert_eq![Int(4_u8).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: u8) -> Int<u8>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo_unchecked(m), 0];
assert_eq![Int(1_u8).modulo_unchecked(m), 1];
assert_eq![Int(2_u8).modulo_unchecked(m), 2];
assert_eq![Int(3_u8).modulo_unchecked(m), 0];
assert_eq![Int(4_u8).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: u8, ) -> Result<ValueQuant<Int<u8>, Int<u8>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_u8).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_u8).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_u8).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: u8, ) -> ValueQuant<Int<u8>, Int<u8>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_u8).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_u8).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_u8).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add(self, other: u8, modulus: u8) -> Result<Int<u8>>

Computes the modulo of self + other over modulus.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_add(0, m)?, 1];
assert_eq![Int(4_u8).modulo_add(1, m)?, 2];
assert_eq![Int(4_u8).modulo_add(2, m)?, 0];
assert_eq![Int(4_u8).modulo_add(3, m)?, 1];
assert_eq![Int(4_u8).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: u8, modulus: u8) -> Int<u8>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: u8, modulus: u8, ) -> Result<ValueQuant<Int<u8>, Int<u8>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u8).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_u8).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_u8).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_u8).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: u8, modulus: u8, ) -> ValueQuant<Int<u8>, Int<u8>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u16.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: u8) -> Result<Int<u8>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo_add_inv(m)?, 0];
assert_eq![Int(1_u8).modulo_add_inv(m)?, 2];
assert_eq![Int(2_u8).modulo_add_inv(m)?, 1];
assert_eq![Int(3_u8).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: u8) -> Int<u8>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: u8, modulus: u8) -> Result<Int<u8>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_sub(0, m)?, 1];
assert_eq![Int(4_u8).modulo_sub(1, m)?, 0];
assert_eq![Int(4_u8).modulo_sub(2, m)?, 2];
assert_eq![Int(4_u8).modulo_sub(3, m)?, 1];
assert_eq![Int(4_u8).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: u8, modulus: u8) -> Int<u8>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: u8, modulus: u8, ) -> Result<ValueQuant<Int<u8>, Int<u8>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u8).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_u8).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_u8).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_u8).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: u8, modulus: u8, ) -> ValueQuant<Int<u8>, Int<u8>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul(self, other: u8, modulus: u8) -> Result<Int<u8>>

Computes the modulo of self + other over modulus.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_mul(0, m)?, 0];
assert_eq![Int(4_u8).modulo_mul(1, m)?, 1];
assert_eq![Int(4_u8).modulo_mul(2, m)?, 2];
assert_eq![Int(4_u8).modulo_mul(3, m)?, 0];
assert_eq![Int(4_u8).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: u8, modulus: u8) -> Int<u8>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: u8, modulus: u8, ) -> Result<ValueQuant<Int<u8>, Int<u8>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u8).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_u8).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_u8).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_u8).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_u8).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: u8, modulus: u8, ) -> ValueQuant<Int<u8>, Int<u8>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u16.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: u8) -> Result<Int<u8>>

Available on crate features _int_i16 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as i16.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_u8).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_u8).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_u8).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_u8).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_u8).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: u8) -> Int<u8>

Available on crate features _int_i16 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as i16.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div(self, other: u8, modulus: u8) -> Result<Int<u8>>

Available on crate features _int_i16 and cast only.

Computes self / other over modulus.

Performs operations internally as i16.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_u8).modulo_div(2, m)?, 0];
assert_eq![Int(1_u8).modulo_div(2, m)?, 2];
assert_eq![Int(2_u8).modulo_div(2, m)?, 1];
assert_eq![Int(3_u8).modulo_div(2, m)?, 0];
assert_eq![Int(4_u8).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: u8, modulus: u8) -> Int<u8>

Available on crate features _int_i16 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as i16.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn modulo(self, modulus: u16) -> Result<Int<u16>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo(m)?, 0];
assert_eq![Int(1_u16).modulo(m)?, 1];
assert_eq![Int(2_u16).modulo(m)?, 2];
assert_eq![Int(3_u16).modulo(m)?, 0];
assert_eq![Int(4_u16).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: u16) -> Int<u16>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo_unchecked(m), 0];
assert_eq![Int(1_u16).modulo_unchecked(m), 1];
assert_eq![Int(2_u16).modulo_unchecked(m), 2];
assert_eq![Int(3_u16).modulo_unchecked(m), 0];
assert_eq![Int(4_u16).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: u16, ) -> Result<ValueQuant<Int<u16>, Int<u16>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_u16).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_u16).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_u16).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: u16, ) -> ValueQuant<Int<u16>, Int<u16>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_u16).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_u16).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_u16).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add(self, other: u16, modulus: u16) -> Result<Int<u16>>

Computes the modulo of self + other over modulus.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_add(0, m)?, 1];
assert_eq![Int(4_u16).modulo_add(1, m)?, 2];
assert_eq![Int(4_u16).modulo_add(2, m)?, 0];
assert_eq![Int(4_u16).modulo_add(3, m)?, 1];
assert_eq![Int(4_u16).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: u16, modulus: u16) -> Int<u16>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: u16, modulus: u16, ) -> Result<ValueQuant<Int<u16>, Int<u16>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u16).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_u16).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_u16).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_u16).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: u16, modulus: u16, ) -> ValueQuant<Int<u16>, Int<u16>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u32.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: u16) -> Result<Int<u16>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo_add_inv(m)?, 0];
assert_eq![Int(1_u16).modulo_add_inv(m)?, 2];
assert_eq![Int(2_u16).modulo_add_inv(m)?, 1];
assert_eq![Int(3_u16).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: u16) -> Int<u16>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: u16, modulus: u16) -> Result<Int<u16>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_sub(0, m)?, 1];
assert_eq![Int(4_u16).modulo_sub(1, m)?, 0];
assert_eq![Int(4_u16).modulo_sub(2, m)?, 2];
assert_eq![Int(4_u16).modulo_sub(3, m)?, 1];
assert_eq![Int(4_u16).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: u16, modulus: u16) -> Int<u16>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: u16, modulus: u16, ) -> Result<ValueQuant<Int<u16>, Int<u16>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u16).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_u16).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_u16).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_u16).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: u16, modulus: u16, ) -> ValueQuant<Int<u16>, Int<u16>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul(self, other: u16, modulus: u16) -> Result<Int<u16>>

Computes the modulo of self + other over modulus.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_mul(0, m)?, 0];
assert_eq![Int(4_u16).modulo_mul(1, m)?, 1];
assert_eq![Int(4_u16).modulo_mul(2, m)?, 2];
assert_eq![Int(4_u16).modulo_mul(3, m)?, 0];
assert_eq![Int(4_u16).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: u16, modulus: u16) -> Int<u16>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: u16, modulus: u16, ) -> Result<ValueQuant<Int<u16>, Int<u16>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u16).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_u16).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_u16).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_u16).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_u16).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: u16, modulus: u16, ) -> ValueQuant<Int<u16>, Int<u16>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u32.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: u16) -> Result<Int<u16>>

Available on crate features _int_i32 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as i32.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_u16).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_u16).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_u16).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_u16).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_u16).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: u16) -> Int<u16>

Available on crate features _int_i32 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as i32.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div(self, other: u16, modulus: u16) -> Result<Int<u16>>

Available on crate features _int_i32 and cast only.

Computes self / other over modulus.

Performs operations internally as i32.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_u16).modulo_div(2, m)?, 0];
assert_eq![Int(1_u16).modulo_div(2, m)?, 2];
assert_eq![Int(2_u16).modulo_div(2, m)?, 1];
assert_eq![Int(3_u16).modulo_div(2, m)?, 0];
assert_eq![Int(4_u16).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: u16, modulus: u16) -> Int<u16>

Available on crate features _int_i32 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as i32.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn modulo(self, modulus: u32) -> Result<Int<u32>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo(m)?, 0];
assert_eq![Int(1_u32).modulo(m)?, 1];
assert_eq![Int(2_u32).modulo(m)?, 2];
assert_eq![Int(3_u32).modulo(m)?, 0];
assert_eq![Int(4_u32).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: u32) -> Int<u32>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo_unchecked(m), 0];
assert_eq![Int(1_u32).modulo_unchecked(m), 1];
assert_eq![Int(2_u32).modulo_unchecked(m), 2];
assert_eq![Int(3_u32).modulo_unchecked(m), 0];
assert_eq![Int(4_u32).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: u32, ) -> Result<ValueQuant<Int<u32>, Int<u32>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_u32).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_u32).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_u32).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: u32, ) -> ValueQuant<Int<u32>, Int<u32>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_u32).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_u32).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_u32).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add(self, other: u32, modulus: u32) -> Result<Int<u32>>

Computes the modulo of self + other over modulus.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_add(0, m)?, 1];
assert_eq![Int(4_u32).modulo_add(1, m)?, 2];
assert_eq![Int(4_u32).modulo_add(2, m)?, 0];
assert_eq![Int(4_u32).modulo_add(3, m)?, 1];
assert_eq![Int(4_u32).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: u32, modulus: u32) -> Int<u32>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: u32, modulus: u32, ) -> Result<ValueQuant<Int<u32>, Int<u32>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u32).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_u32).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_u32).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_u32).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: u32, modulus: u32, ) -> ValueQuant<Int<u32>, Int<u32>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u64.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: u32) -> Result<Int<u32>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo_add_inv(m)?, 0];
assert_eq![Int(1_u32).modulo_add_inv(m)?, 2];
assert_eq![Int(2_u32).modulo_add_inv(m)?, 1];
assert_eq![Int(3_u32).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: u32) -> Int<u32>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: u32, modulus: u32) -> Result<Int<u32>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_sub(0, m)?, 1];
assert_eq![Int(4_u32).modulo_sub(1, m)?, 0];
assert_eq![Int(4_u32).modulo_sub(2, m)?, 2];
assert_eq![Int(4_u32).modulo_sub(3, m)?, 1];
assert_eq![Int(4_u32).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: u32, modulus: u32) -> Int<u32>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: u32, modulus: u32, ) -> Result<ValueQuant<Int<u32>, Int<u32>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u32).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_u32).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_u32).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_u32).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: u32, modulus: u32, ) -> ValueQuant<Int<u32>, Int<u32>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul(self, other: u32, modulus: u32) -> Result<Int<u32>>

Computes the modulo of self + other over modulus.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_mul(0, m)?, 0];
assert_eq![Int(4_u32).modulo_mul(1, m)?, 1];
assert_eq![Int(4_u32).modulo_mul(2, m)?, 2];
assert_eq![Int(4_u32).modulo_mul(3, m)?, 0];
assert_eq![Int(4_u32).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: u32, modulus: u32) -> Int<u32>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: u32, modulus: u32, ) -> Result<ValueQuant<Int<u32>, Int<u32>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u32).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_u32).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_u32).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_u32).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_u32).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: u32, modulus: u32, ) -> ValueQuant<Int<u32>, Int<u32>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u64.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: u32) -> Result<Int<u32>>

Available on crate features _int_i64 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as i64.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_u32).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_u32).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_u32).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_u32).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_u32).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: u32) -> Int<u32>

Available on crate features _int_i64 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as i64.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div(self, other: u32, modulus: u32) -> Result<Int<u32>>

Available on crate features _int_i64 and cast only.

Computes self / other over modulus.

Performs operations internally as i64.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_u32).modulo_div(2, m)?, 0];
assert_eq![Int(1_u32).modulo_div(2, m)?, 2];
assert_eq![Int(2_u32).modulo_div(2, m)?, 1];
assert_eq![Int(3_u32).modulo_div(2, m)?, 0];
assert_eq![Int(4_u32).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: u32, modulus: u32) -> Int<u32>

Available on crate features _int_i64 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as i64.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn modulo(self, modulus: u64) -> Result<Int<u64>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo(m)?, 0];
assert_eq![Int(1_u64).modulo(m)?, 1];
assert_eq![Int(2_u64).modulo(m)?, 2];
assert_eq![Int(3_u64).modulo(m)?, 0];
assert_eq![Int(4_u64).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: u64) -> Int<u64>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo_unchecked(m), 0];
assert_eq![Int(1_u64).modulo_unchecked(m), 1];
assert_eq![Int(2_u64).modulo_unchecked(m), 2];
assert_eq![Int(3_u64).modulo_unchecked(m), 0];
assert_eq![Int(4_u64).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: u64, ) -> Result<ValueQuant<Int<u64>, Int<u64>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_u64).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_u64).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_u64).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: u64, ) -> ValueQuant<Int<u64>, Int<u64>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_u64).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_u64).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_u64).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add(self, other: u64, modulus: u64) -> Result<Int<u64>>

Computes the modulo of self + other over modulus.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_add(0, m)?, 1];
assert_eq![Int(4_u64).modulo_add(1, m)?, 2];
assert_eq![Int(4_u64).modulo_add(2, m)?, 0];
assert_eq![Int(4_u64).modulo_add(3, m)?, 1];
assert_eq![Int(4_u64).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: u64, modulus: u64) -> Int<u64>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: u64, modulus: u64, ) -> Result<ValueQuant<Int<u64>, Int<u64>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u64).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_u64).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_u64).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_u64).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: u64, modulus: u64, ) -> ValueQuant<Int<u64>, Int<u64>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u128.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: u64) -> Result<Int<u64>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo_add_inv(m)?, 0];
assert_eq![Int(1_u64).modulo_add_inv(m)?, 2];
assert_eq![Int(2_u64).modulo_add_inv(m)?, 1];
assert_eq![Int(3_u64).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: u64) -> Int<u64>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: u64, modulus: u64) -> Result<Int<u64>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_sub(0, m)?, 1];
assert_eq![Int(4_u64).modulo_sub(1, m)?, 0];
assert_eq![Int(4_u64).modulo_sub(2, m)?, 2];
assert_eq![Int(4_u64).modulo_sub(3, m)?, 1];
assert_eq![Int(4_u64).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: u64, modulus: u64) -> Int<u64>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: u64, modulus: u64, ) -> Result<ValueQuant<Int<u64>, Int<u64>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u64).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_u64).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_u64).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_u64).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: u64, modulus: u64, ) -> ValueQuant<Int<u64>, Int<u64>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul(self, other: u64, modulus: u64) -> Result<Int<u64>>

Computes the modulo of self + other over modulus.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_mul(0, m)?, 0];
assert_eq![Int(4_u64).modulo_mul(1, m)?, 1];
assert_eq![Int(4_u64).modulo_mul(2, m)?, 2];
assert_eq![Int(4_u64).modulo_mul(3, m)?, 0];
assert_eq![Int(4_u64).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: u64, modulus: u64) -> Int<u64>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: u64, modulus: u64, ) -> Result<ValueQuant<Int<u64>, Int<u64>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u64).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_u64).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_u64).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_u64).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_u64).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: u64, modulus: u64, ) -> ValueQuant<Int<u64>, Int<u64>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u128.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: u64) -> Result<Int<u64>>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as i128.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_u64).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_u64).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_u64).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_u64).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_u64).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: u64) -> Int<u64>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as i128.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div(self, other: u64, modulus: u64) -> Result<Int<u64>>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus.

Performs operations internally as i128.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_u64).modulo_div(2, m)?, 0];
assert_eq![Int(1_u64).modulo_div(2, m)?, 2];
assert_eq![Int(2_u64).modulo_div(2, m)?, 1];
assert_eq![Int(3_u64).modulo_div(2, m)?, 0];
assert_eq![Int(4_u64).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: u64, modulus: u64) -> Int<u64>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn modulo(self, modulus: u128) -> Result<Int<u128>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo(m)?, 0];
assert_eq![Int(1_u128).modulo(m)?, 1];
assert_eq![Int(2_u128).modulo(m)?, 2];
assert_eq![Int(3_u128).modulo(m)?, 0];
assert_eq![Int(4_u128).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: u128) -> Int<u128>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo_unchecked(m), 0];
assert_eq![Int(1_u128).modulo_unchecked(m), 1];
assert_eq![Int(2_u128).modulo_unchecked(m), 2];
assert_eq![Int(3_u128).modulo_unchecked(m), 0];
assert_eq![Int(4_u128).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: u128, ) -> Result<ValueQuant<Int<u128>, Int<u128>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_u128).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_u128).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_u128).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: u128, ) -> ValueQuant<Int<u128>, Int<u128>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_u128).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_u128).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_u128).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add(self, other: u128, modulus: u128) -> Result<Int<u128>>

Computes the modulo of self + other over modulus.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_add(0, m)?, 1];
assert_eq![Int(4_u128).modulo_add(1, m)?, 2];
assert_eq![Int(4_u128).modulo_add(2, m)?, 0];
assert_eq![Int(4_u128).modulo_add(3, m)?, 1];
assert_eq![Int(4_u128).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked(self, other: u128, modulus: u128) -> Int<u128>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: u128, modulus: u128, ) -> Result<ValueQuant<Int<u128>, Int<u128>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u128).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_u128).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_u128).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_u128).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: u128, modulus: u128, ) -> ValueQuant<Int<u128>, Int<u128>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u128.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: u128) -> Result<Int<u128>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo_add_inv(m)?, 0];
assert_eq![Int(1_u128).modulo_add_inv(m)?, 2];
assert_eq![Int(2_u128).modulo_add_inv(m)?, 1];
assert_eq![Int(3_u128).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: u128) -> Int<u128>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub(self, other: u128, modulus: u128) -> Result<Int<u128>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_sub(0, m)?, 1];
assert_eq![Int(4_u128).modulo_sub(1, m)?, 0];
assert_eq![Int(4_u128).modulo_sub(2, m)?, 2];
assert_eq![Int(4_u128).modulo_sub(3, m)?, 1];
assert_eq![Int(4_u128).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked(self, other: u128, modulus: u128) -> Int<u128>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: u128, modulus: u128, ) -> Result<ValueQuant<Int<u128>, Int<u128>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_u128).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_u128).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_u128).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_u128).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: u128, modulus: u128, ) -> ValueQuant<Int<u128>, Int<u128>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul(self, other: u128, modulus: u128) -> Result<Int<u128>>

Computes the modulo of self + other over modulus.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_mul(0, m)?, 0];
assert_eq![Int(4_u128).modulo_mul(1, m)?, 1];
assert_eq![Int(4_u128).modulo_mul(2, m)?, 2];
assert_eq![Int(4_u128).modulo_mul(3, m)?, 0];
assert_eq![Int(4_u128).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked(self, other: u128, modulus: u128) -> Int<u128>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: u128, modulus: u128, ) -> Result<ValueQuant<Int<u128>, Int<u128>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_u128).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_u128).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_u128).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_u128).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_u128).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: u128, modulus: u128, ) -> ValueQuant<Int<u128>, Int<u128>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as u128.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: u128) -> Result<Int<u128>>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as i128.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_u128).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_u128).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_u128).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_u128).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_u128).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: u128) -> Int<u128>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as i128.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div(self, other: u128, modulus: u128) -> Result<Int<u128>>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus.

Performs operations internally as i128.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_u128).modulo_div(2, m)?, 0];
assert_eq![Int(1_u128).modulo_div(2, m)?, 2];
assert_eq![Int(2_u128).modulo_div(2, m)?, 1];
assert_eq![Int(3_u128).modulo_div(2, m)?, 0];
assert_eq![Int(4_u128).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked(self, other: u128, modulus: u128) -> Int<u128>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as i128.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn modulo(self, modulus: usize) -> Result<Int<usize>>

Computes the non-negative modulo of self over modulus.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo(m)?, 0];
assert_eq![Int(1_usize).modulo(m)?, 1];
assert_eq![Int(2_usize).modulo(m)?, 2];
assert_eq![Int(3_usize).modulo(m)?, 0];
assert_eq![Int(4_usize).modulo(m)?, 1];
Source

pub const fn modulo_unchecked(self, modulus: usize) -> Int<usize>

Computes the non-negative modulo of self over modulus, unchecked version.

The result is less than the value of modulus, i.e., in the range $ [0, \text{modulus}) $.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo_unchecked(m), 0];
assert_eq![Int(1_usize).modulo_unchecked(m), 1];
assert_eq![Int(2_usize).modulo_unchecked(m), 2];
assert_eq![Int(3_usize).modulo_unchecked(m), 0];
assert_eq![Int(4_usize).modulo_unchecked(m), 1];
Source

pub const fn modulo_cycles( self, modulus: usize, ) -> Result<ValueQuant<Int<usize>, Int<usize>>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo_cycles(m)?, (0, 0)];
assert_eq![Int(1_usize).modulo_cycles(m)?, (1, 0)];
assert_eq![Int(2_usize).modulo_cycles(m)?, (2, 0)];
assert_eq![Int(3_usize).modulo_cycles(m)?, (0, 1)];
Source

pub const fn modulo_cycles_unchecked( self, modulus: usize, ) -> ValueQuant<Int<usize>, Int<usize>>

Computes the non-negative modulo of self over modulus, and the number of cycles it is reduced, unchecked version.

§Panics

Panics if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo_cycles_unchecked(m), (0, 0)];
assert_eq![Int(1_usize).modulo_cycles_unchecked(m), (1, 0)];
assert_eq![Int(2_usize).modulo_cycles_unchecked(m), (2, 0)];
assert_eq![Int(3_usize).modulo_cycles_unchecked(m), (0, 1)];
Source

pub const fn modulo_add( self, other: usize, modulus: usize, ) -> Result<Int<usize>>

Computes the modulo of self + other over modulus.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_add(0, m)?, 1];
assert_eq![Int(4_usize).modulo_add(1, m)?, 2];
assert_eq![Int(4_usize).modulo_add(2, m)?, 0];
assert_eq![Int(4_usize).modulo_add(3, m)?, 1];
assert_eq![Int(4_usize).modulo_add(4, m)?, 2];
Source

pub const fn modulo_add_unchecked( self, other: usize, modulus: usize, ) -> Int<usize>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_add_cycles( self, other: usize, modulus: usize, ) -> Result<ValueQuant<Int<usize>, Int<usize>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_add since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_add_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_usize).modulo_add_cycles(1, m)?, (2, 1)];
assert_eq![Int(4_usize).modulo_add_cycles(2, m)?, (0, 2)];
assert_eq![Int(4_usize).modulo_add_cycles(3, m)?, (1, 2)];
assert_eq![Int(4_usize).modulo_add_cycles(4, m)?, (2, 2)];
Source

pub const fn modulo_add_cycles_unchecked( self, other: usize, modulus: usize, ) -> ValueQuant<Int<usize>, Int<usize>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as usize_up.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_add_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_add_inv(self, modulus: usize) -> Result<Int<usize>>

Calculates the modular additive inverse.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Errors

Returns NonZeroRequired if modulus == 0.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo_add_inv(m)?, 0];
assert_eq![Int(1_usize).modulo_add_inv(m)?, 2];
assert_eq![Int(2_usize).modulo_add_inv(m)?, 1];
assert_eq![Int(3_usize).modulo_add_inv(m)?, 0];
Source

pub const fn modulo_add_inv_unchecked(self, modulus: usize) -> Int<usize>

Calculates the modular additive inverse, unchecked version.

The modular additive inverse of self modulo modulus is an integer b such that $ a+b \equiv 0 (\mod m) $.

The modular multiplicative inverse always exists and is simply modulus - self if self != 0, or 0 otherwise.

§Panics

Panics if modulus == 0.

Source

pub const fn modulo_sub( self, other: usize, modulus: usize, ) -> Result<Int<usize>>

Computes the modulo of self - other over modulus.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_sub(0, m)?, 1];
assert_eq![Int(4_usize).modulo_sub(1, m)?, 0];
assert_eq![Int(4_usize).modulo_sub(2, m)?, 2];
assert_eq![Int(4_usize).modulo_sub(3, m)?, 1];
assert_eq![Int(4_usize).modulo_sub(4, m)?, 0];
Source

pub const fn modulo_sub_unchecked( self, other: usize, modulus: usize, ) -> Int<usize>

Computes the modulo of self - other over modulus, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_sub_cycles( self, other: usize, modulus: usize, ) -> Result<ValueQuant<Int<usize>, Int<usize>>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced.

§Errors

Returns NonZeroRequired if modulus == 0, and it can also return Overflow if the result would be a negative value.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_sub_cycles(0, m)?, (1, 1)];
assert_eq![Int(4_usize).modulo_sub_cycles(1, m)?, (0, 1)];
assert_eq![Int(4_usize).modulo_sub_cycles(2, m)?, (2, 0)];
assert_eq![Int(4_usize).modulo_sub_cycles(3, m)?, (1, 0)];
assert_eq![Int(4_usize).modulo_sub_cycles(4, m)?, (0, 0)];
Source

pub const fn modulo_sub_cycles_unchecked( self, other: usize, modulus: usize, ) -> ValueQuant<Int<usize>, Int<usize>>

Computes the modulo of self - other over modulus, and the number of cycles the result is reduced, unchecked version.

§Panics

Panics if modulus == 0, and if the result would be a negative value.

Source

pub const fn modulo_mul( self, other: usize, modulus: usize, ) -> Result<Int<usize>>

Computes the modulo of self + other over modulus.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it could also return Overflow.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_mul(0, m)?, 0];
assert_eq![Int(4_usize).modulo_mul(1, m)?, 1];
assert_eq![Int(4_usize).modulo_mul(2, m)?, 2];
assert_eq![Int(4_usize).modulo_mul(3, m)?, 0];
assert_eq![Int(4_usize).modulo_mul(4, m)?, 1];
Source

pub const fn modulo_mul_unchecked( self, other: usize, modulus: usize, ) -> Int<usize>

Computes the modulo of self + other over modulus, unchecked version.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Panics

Panics if modulus == 0, and for u128 it could also panic on overflow.

Source

pub const fn modulo_mul_cycles( self, other: usize, modulus: usize, ) -> Result<ValueQuant<Int<usize>, Int<usize>>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonZeroRequired if modulus == 0, and for u128 it can also return Overflow, more probably than in modulo_mul since we can’t reduce the operands beforehand in order to calculate times.

§Examples
let m = 3;
assert_eq![Int(4_usize).modulo_mul_cycles(0, m)?, (0, 0)];
assert_eq![Int(4_usize).modulo_mul_cycles(1, m)?, (1, 1)];
assert_eq![Int(4_usize).modulo_mul_cycles(2, m)?, (2, 2)];
assert_eq![Int(4_usize).modulo_mul_cycles(3, m)?, (0, 4)];
assert_eq![Int(4_usize).modulo_mul_cycles(4, m)?, (1, 5)];
Source

pub const fn modulo_mul_cycles_unchecked( self, other: usize, modulus: usize, ) -> ValueQuant<Int<usize>, Int<usize>>

Computes the modulo of self + other over modulus, and the number of cycles the result is reduced, unchecked version.

Performs operations internally as usize_up.

§Panics

Panics if modulus == 0, and for u128 it can also panic on overflow, more probably than in modulo_mul_unchecked since we can’t reduce the operands beforehand in order to calculate times.

Source

pub const fn modulo_mul_inv(self, modulus: usize) -> Result<Int<usize>>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse.

Performs operations internally as isize_up.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no inverse, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 5;
assert_eq![Int(0_usize).modulo_mul_inv(m), Err(NumError::NoInverse)];
assert_eq![Int(1_usize).modulo_mul_inv(m)?, 1];
assert_eq![Int(2_usize).modulo_mul_inv(m)?, 3];
assert_eq![Int(3_usize).modulo_mul_inv(m)?, 2];
assert_eq![Int(4_usize).modulo_mul_inv(m)?, 4];
Source

pub const fn modulo_mul_inv_unchecked(self, modulus: usize) -> Int<usize>

Available on crate features _int_i128 and cast only.

Calculates the modular multiplicative inverse, unchecked version.

Performs operations internally as isize_up.

The modular multiplicative inverse of a modulo m is an integer b such that $ ab \equiv 1 (\mod m) $.

The modular multiplicative inverse exists only if self and modulus are coprime, meaning their greatest common divisor is 1.

§Panics

Panics if modulus == 0, if there’s no inverse, and for u128 it could overflow when casting in the gcd_ext calculation.

Source

pub const fn modulo_div( self, other: usize, modulus: usize, ) -> Result<Int<usize>>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus.

Performs operations internally as isize_up.

$a / b \mod m$ is equivalent to $a * b^{-1} \mod m$, where $b^{-1}$ is the modular multiplicative inverse of $b$ modulo $m$.

§Errors

Returns NonZeroRequired if modulus == 0, NoInverse if there’s no multiplicative inverse of other, and for u128 it could return Overflow when casting in the gcd_ext calculation.

§Examples
let m = 3;
assert_eq![Int(0_usize).modulo_div(2, m)?, 0];
assert_eq![Int(1_usize).modulo_div(2, m)?, 2];
assert_eq![Int(2_usize).modulo_div(2, m)?, 1];
assert_eq![Int(3_usize).modulo_div(2, m)?, 0];
assert_eq![Int(4_usize).modulo_div(2, m)?, 2];
Source

pub const fn modulo_div_unchecked( self, other: usize, modulus: usize, ) -> Int<usize>

Available on crate features _int_i128 and cast only.

Computes self / other over modulus, unchecked version.

Performs operations internally as isize_up.

§Panics

Panics if modulus == 0, if there’s no multiplicative inverse of other. and for u128 it could overflow when casting in the gcd_ext calculation.

Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_i8).is_prime()];
assert![Int(2_i8).is_prime()];
assert![!Int(1_i8).is_prime()];
assert![!Int(-2_i8).is_prime()];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<i8>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_i8).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_i8).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_i8).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_i8).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to i16 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_i8).prime_pi()];
assert_eq![2, Int(3_i8).prime_pi()];
assert_eq![31, Int(127_i8).prime_pi()];
assert_eq![0, Int(-5_i8).prime_pi()];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn totient(self) -> Int<i8>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_i8).totient()];
assert_eq![Int(6), Int(9_i8).totient()];
assert_eq![Int(12), Int(13_i8).totient()];
assert_eq![Int(22), Int(-23_i8).totient()];
assert_eq![Int(2), Int(-3_i8).totient()];
Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_i16).is_prime()];
assert![Int(2_i16).is_prime()];
assert![!Int(1_i16).is_prime()];
assert![!Int(-2_i16).is_prime()];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<i16>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_i16).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_i16).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_i16).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_i16).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to i32 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_i16).prime_pi()];
assert_eq![2, Int(3_i16).prime_pi()];
assert_eq![31, Int(127_i16).prime_pi()];
assert_eq![0, Int(-5_i16).prime_pi()];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn totient(self) -> Int<i16>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_i16).totient()];
assert_eq![Int(6), Int(9_i16).totient()];
assert_eq![Int(12), Int(13_i16).totient()];
assert_eq![Int(22), Int(-23_i16).totient()];
assert_eq![Int(2), Int(-3_i16).totient()];
Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_i32).is_prime()];
assert![Int(2_i32).is_prime()];
assert![!Int(1_i32).is_prime()];
assert![!Int(-2_i32).is_prime()];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<i32>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_i32).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_i32).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_i32).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_i32).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to i64 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_i32).prime_pi()];
assert_eq![2, Int(3_i32).prime_pi()];
assert_eq![31, Int(127_i32).prime_pi()];
assert_eq![0, Int(-5_i32).prime_pi()];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn totient(self) -> Int<i32>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_i32).totient()];
assert_eq![Int(6), Int(9_i32).totient()];
assert_eq![Int(12), Int(13_i32).totient()];
assert_eq![Int(22), Int(-23_i32).totient()];
assert_eq![Int(2), Int(-3_i32).totient()];
Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_i64).is_prime()];
assert![Int(2_i64).is_prime()];
assert![!Int(1_i64).is_prime()];
assert![!Int(-2_i64).is_prime()];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<i64>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_i64).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_i64).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_i64).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_i64).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to i128 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_i64).prime_pi()];
assert_eq![2, Int(3_i64).prime_pi()];
assert_eq![31, Int(127_i64).prime_pi()];
assert_eq![0, Int(-5_i64).prime_pi()];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn totient(self) -> Int<i64>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_i64).totient()];
assert_eq![Int(6), Int(9_i64).totient()];
assert_eq![Int(12), Int(13_i64).totient()];
assert_eq![Int(22), Int(-23_i64).totient()];
assert_eq![Int(2), Int(-3_i64).totient()];
Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_i128).is_prime()];
assert![Int(2_i128).is_prime()];
assert![!Int(1_i128).is_prime()];
assert![!Int(-2_i128).is_prime()];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<i128>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_i128).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_i128).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_i128).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_i128).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to i128 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_i128).prime_pi()];
assert_eq![2, Int(3_i128).prime_pi()];
assert_eq![31, Int(127_i128).prime_pi()];
assert_eq![0, Int(-5_i128).prime_pi()];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn totient(self) -> Int<i128>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_i128).totient()];
assert_eq![Int(6), Int(9_i128).totient()];
assert_eq![Int(12), Int(13_i128).totient()];
assert_eq![Int(22), Int(-23_i128).totient()];
assert_eq![Int(2), Int(-3_i128).totient()];
Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_isize).is_prime()];
assert![Int(2_isize).is_prime()];
assert![!Int(1_isize).is_prime()];
assert![!Int(-2_isize).is_prime()];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<isize>>

Finds the 0-indexed nth prime number.

Note: If nth is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3, and the function will return the 3rd prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_isize).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_isize).prime_nth()];
assert_eq![Ok(Int(127)), Int(30_isize).prime_nth()];
assert_eq![Ok(Int(127)), Int(-30_isize).prime_nth()];
assert![Int(31_i8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to isize_up for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_isize).prime_pi()];
assert_eq![2, Int(3_isize).prime_pi()];
assert_eq![31, Int(127_isize).prime_pi()];
assert_eq![0, Int(-5_isize).prime_pi()];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn totient(self) -> Int<isize>

Counts the number of integers $<|n|$ that are relatively prime to n.

Note: If n is negative, this function treats it as its absolute value. For example, a value of -3 will be treated as 3.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_isize).totient()];
assert_eq![Int(6), Int(9_isize).totient()];
assert_eq![Int(12), Int(13_isize).totient()];
assert_eq![Int(22), Int(-23_isize).totient()];
assert_eq![Int(2), Int(-3_isize).totient()];
Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_u8).is_prime()];
assert![Int(2_u8).is_prime()];
assert![!Int(1_u8).is_prime()];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<u8>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_u8).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_u8).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_u8).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to u16 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_u8).prime_pi()];
assert_eq![2, Int(3_u8).prime_pi()];
assert_eq![31, Int(127_u8).prime_pi()];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn totient(self) -> Int<u8>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_u8).totient()];
assert_eq![Int(6), Int(9_u8).totient()];
assert_eq![Int(12), Int(13_u8).totient()];
Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_u16).is_prime()];
assert![Int(2_u16).is_prime()];
assert![!Int(1_u16).is_prime()];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<u16>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_u16).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_u16).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_u16).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to u32 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_u16).prime_pi()];
assert_eq![2, Int(3_u16).prime_pi()];
assert_eq![31, Int(127_u16).prime_pi()];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn totient(self) -> Int<u16>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_u16).totient()];
assert_eq![Int(6), Int(9_u16).totient()];
assert_eq![Int(12), Int(13_u16).totient()];
Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_u32).is_prime()];
assert![Int(2_u32).is_prime()];
assert![!Int(1_u32).is_prime()];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<u32>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_u32).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_u32).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_u32).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to u64 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_u32).prime_pi()];
assert_eq![2, Int(3_u32).prime_pi()];
assert_eq![31, Int(127_u32).prime_pi()];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn totient(self) -> Int<u32>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_u32).totient()];
assert_eq![Int(6), Int(9_u32).totient()];
assert_eq![Int(12), Int(13_u32).totient()];
Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_u64).is_prime()];
assert![Int(2_u64).is_prime()];
assert![!Int(1_u64).is_prime()];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<u64>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_u64).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_u64).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_u64).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to u128 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_u64).prime_pi()];
assert_eq![2, Int(3_u64).prime_pi()];
assert_eq![31, Int(127_u64).prime_pi()];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn totient(self) -> Int<u64>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_u64).totient()];
assert_eq![Int(6), Int(9_u64).totient()];
assert_eq![Int(12), Int(13_u64).totient()];
Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_u128).is_prime()];
assert![Int(2_u128).is_prime()];
assert![!Int(1_u128).is_prime()];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn prime_nth(self) -> Result<Int<u128>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_u128).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_u128).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_u128).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to u128 for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_u128).prime_pi()];
assert_eq![2, Int(3_u128).prime_pi()];
assert_eq![31, Int(127_u128).prime_pi()];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn totient(self) -> Int<u128>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_u128).totient()];
assert_eq![Int(6), Int(9_u128).totient()];
assert_eq![Int(12), Int(13_u128).totient()];
Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn is_prime(self) -> bool

Returns true if n is prime.

This approach uses optimized trial division, which means it checks only odd numbers starting from 3 and up to the square root of the given number. This is based on the fact that if a number is divisible by a number larger than its square root, the result of the division will be smaller than the square root, and it would have already been checked in previous iterations.

§Examples
assert![Int(127_usize).is_prime()];
assert![Int(2_usize).is_prime()];
assert![!Int(1_usize).is_prime()];
Source

pub const fn prime_nth(self) -> Result<Int<usize>>

Finds the 0-indexed nth prime number.

§Errors

Returns Overflow if the result can’t fit the type.

§Examples
assert_eq![Ok(Int(2)), Int(0_usize).prime_nth()];
assert_eq![Ok(Int(3)), Int(1_usize).prime_nth()];
assert_eq![Ok(Int(251)), Int(53_usize).prime_nth()];
assert![Int(54_u8).prime_nth().is_err()];
Source

pub const fn prime_pi(self) -> usize

Counts the number of primes upto and including n.

$$ \pi(x) $$

It upcasts internally to usize_up for the inner operations.

§Panics

It can panic if n == i128|u128, at the last iteration of a loop that would take an unfeasable amount of time.

§Examples
assert_eq![1, Int(2_usize).prime_pi()];
assert_eq![2, Int(3_usize).prime_pi()];
assert_eq![31, Int(127_usize).prime_pi()];
Source

pub const fn totient(self) -> Int<usize>

Counts the number of integers $<n$ that are relatively prime to n.

§Formulation
§Algorithm

This function iterates through all numbers from 2 up to the square root of $|n|$. If it finds a divisor, it reduces n by its factors and adjusts result accordingly. If after the loop, $n > 1$, it means n has a prime factor greater than its square root, and the function adjusts result for this last factor. $$\large\varphi(n) =n \prod_{p\mid |n|} \left(1-\frac{1}{p}\right)$$

§Examples
assert_eq![Int(2), Int(4_usize).totient()];
assert_eq![Int(6), Int(9_usize).totient()];
assert_eq![Int(12), Int(13_usize).totient()];
Source§

impl Int<i8>

Available on crate feature _int_i8 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_i8).is_square(), false];
assert_eq![Int(13_i8).is_square(), false];
assert_eq![Int(16_i8).is_square(), true];
assert_eq![Int(20_i8).is_square(), false];
assert_eq![Int(21_i8).is_square(), false];
assert_eq![Int(-16_i8).is_square(), false];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<i8>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i8).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_i8).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_i8).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_i8).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_i8).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_i8).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<i8>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_i8).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_i8).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_i8).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_i8).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_i8).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_i8).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i8 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<i8>>

Returns the rounded integer square root.

Performs operations internally as i16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i8).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_i8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_i8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_i8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_i8).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_i8).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<i8>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_i8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_i8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_i8).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_i8).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81i8).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(i8::MAX).root_ceil(1), Ok(Int(i8::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<i8>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i8).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_i8).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_i8).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_i8).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_i8).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_i8).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(i8::MAX).root_floor(1), Ok(Int(i8::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<i16>

Available on crate feature _int_i16 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_i16).is_square(), false];
assert_eq![Int(13_i16).is_square(), false];
assert_eq![Int(16_i16).is_square(), true];
assert_eq![Int(20_i16).is_square(), false];
assert_eq![Int(21_i16).is_square(), false];
assert_eq![Int(-16_i16).is_square(), false];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<i16>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i16).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_i16).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_i16).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_i16).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_i16).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_i16).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<i16>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_i16).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_i16).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_i16).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_i16).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_i16).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_i16).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i16 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<i16>>

Returns the rounded integer square root.

Performs operations internally as i32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i16).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_i16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_i16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_i16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_i16).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_i16).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<i16>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_i16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_i16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_i16).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_i16).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81i16).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(i16::MAX).root_ceil(1), Ok(Int(i16::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<i16>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i16).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_i16).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_i16).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_i16).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_i16).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_i16).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(i16::MAX).root_floor(1), Ok(Int(i16::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<i32>

Available on crate feature _int_i32 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_i32).is_square(), false];
assert_eq![Int(13_i32).is_square(), false];
assert_eq![Int(16_i32).is_square(), true];
assert_eq![Int(20_i32).is_square(), false];
assert_eq![Int(21_i32).is_square(), false];
assert_eq![Int(-16_i32).is_square(), false];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<i32>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i32).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_i32).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_i32).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_i32).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_i32).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_i32).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<i32>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_i32).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_i32).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_i32).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_i32).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_i32).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_i32).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i32 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<i32>>

Returns the rounded integer square root.

Performs operations internally as i64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i32).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_i32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_i32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_i32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_i32).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_i32).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<i32>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_i32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_i32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_i32).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_i32).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81i32).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(i32::MAX).root_ceil(1), Ok(Int(i32::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<i32>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i32).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_i32).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_i32).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_i32).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_i32).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_i32).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(i32::MAX).root_floor(1), Ok(Int(i32::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<i64>

Available on crate feature _int_i64 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_i64).is_square(), false];
assert_eq![Int(13_i64).is_square(), false];
assert_eq![Int(16_i64).is_square(), true];
assert_eq![Int(20_i64).is_square(), false];
assert_eq![Int(21_i64).is_square(), false];
assert_eq![Int(-16_i64).is_square(), false];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<i64>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i64).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_i64).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_i64).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_i64).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_i64).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_i64).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<i64>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_i64).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_i64).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_i64).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_i64).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_i64).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_i64).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i64 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<i64>>

Returns the rounded integer square root.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i64).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_i64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_i64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_i64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_i64).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_i64).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<i64>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_i64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_i64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_i64).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_i64).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81i64).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(i64::MAX).root_ceil(1), Ok(Int(i64::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<i64>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i64).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_i64).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_i64).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_i64).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_i64).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_i64).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(i64::MAX).root_floor(1), Ok(Int(i64::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<i128>

Available on crate feature _int_i128 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_i128).is_square(), false];
assert_eq![Int(13_i128).is_square(), false];
assert_eq![Int(16_i128).is_square(), true];
assert_eq![Int(20_i128).is_square(), false];
assert_eq![Int(21_i128).is_square(), false];
assert_eq![Int(-16_i128).is_square(), false];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<i128>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i128).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_i128).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_i128).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_i128).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_i128).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_i128).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<i128>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_i128).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_i128).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_i128).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_i128).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_i128).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_i128).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_i128 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<i128>>

Returns the rounded integer square root.

Performs operations internally as i128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_i128).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_i128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_i128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_i128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_i128).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_i128).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<i128>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_i128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_i128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_i128).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_i128).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81i128).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(i128::MAX).root_ceil(1), Ok(Int(i128::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<i128>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_i128).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_i128).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_i128).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_i128).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_i128).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_i128).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(i128::MAX).root_floor(1), Ok(Int(i128::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<isize>

Available on crate feature _int_isize only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square.

Returns false otherwise, which includes all negative values. $$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_isize).is_square(), false];
assert_eq![Int(13_isize).is_square(), false];
assert_eq![Int(16_isize).is_square(), true];
assert_eq![Int(20_isize).is_square(), false];
assert_eq![Int(21_isize).is_square(), false];
assert_eq![Int(-16_isize).is_square(), false];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Result<Int<isize>>

Returns the ceiled integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_isize).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(13_isize).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(16_isize).sqrt_ceil(), Ok(Int(4))];
assert_eq![Int(20_isize).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(21_isize).sqrt_ceil(), Ok(Int(5))];
assert_eq![Int(-4_isize).sqrt_ceil(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn sqrt_floor(self) -> Result<Int<isize>>

Returns the floored integer square root.

§Errors

Returns NonNegativeRequired if self is negative.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_isize).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(13_isize).sqrt_floor(), Ok(Int(3))];
assert_eq![Int(16_isize).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(20_isize).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(21_isize).sqrt_floor(), Ok(Int(4))];
assert_eq![Int(-4_isize).sqrt_floor(), Err(NonNegativeRequired)];
§Features

This will only be const if the _cmp_isize feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<isize>>

Returns the rounded integer square root.

Performs operations internally as isize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Returns NonNegativeRequired if self is negative, or possibly Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_isize).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_isize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_isize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_isize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_isize).sqrt_round(), Ok(Int(5))];
assert_eq![Int(-4_isize).sqrt_round(), Err(NonNegativeRequired)];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<isize>>

Returns the ceiled integer nth root.

$$ \large \left\lceil |a|^{\frac{1}{n}} \right\rceil \cdot \text{sign}(a) = m $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_isize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_isize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_isize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_isize).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_isize).root_ceil(4), Ok(Int(4))];
assert_eq![Int(-81isize).root_ceil(4), Err(NonNegativeRequired)];
assert_eq![Int(isize::MAX).root_ceil(1), Ok(Int(isize::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n \% 2 = 0, \text{ then error.} \cr \notag m = \lfloor |a|^{\frac{1}{n}} \rfloor \cr \notag \left\lceil |a|^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = |a|, \cr m+1 & \text{if } m^n < |a|. \end{cases} \cr \notag \text{Output: } m \cdot \text{sign}(a) \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq |a|. $$ Subject to the condition: $$ \large a < 0 \quad \text{and} \quad n \% 2 = 0 \quad \text{is invalid.} $$ The process is as follows:

  1. Iteratively tests values starting from $ m = 1 $, calculating $ m^n $ until $ m^n > |a| $.
  2. Computes the floored nth root as $ m - 1 $.
  3. Checks if $ (m - 1)^n = |a| $.
    • If true, returns $ m - 1 \cdot \text{sign}(a) $.
    • Otherwise, returns $ m \cdot \text{sign}(a) $, the smallest integer such that $ m^n \geq |a| $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<isize>>

Returns the floored integer nth root.

$$ \large \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $$

§Errors

Returns NonZeroRequired if nth is 0, or NonNegativeRequired if self is negative and nth is even.

§Examples
assert_eq![Int(48_isize).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_isize).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_isize).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_isize).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_isize).root_floor(4), Ok(Int(3))];
assert_eq![Int(-81_isize).root_floor(4), Err(NonNegativeRequired)];
assert_eq![Int(isize::MAX).root_floor(1), Ok(Int(isize::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag \text{If } a < 0 \text{ and } n % 2 = 0, \text{ then error.} \cr \notag m = \max { k \in \Z \mid k^n \leq |a| } \cr \notag \text{Output: } m \cdot \text{sign}(a) & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor |a|^{\frac{1}{n}} \right\rfloor = m \cdot \text{sign}(a) $, where $ m $ is the largest integer such that: $$ \large m^n \leq |a|, $$ subject to the condition: $$ \large a < 0 \quad \text{and} \quad n % 2 = 0 \quad \text{is invalid.} $$ The algorithm incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > |a|. $$ The function then returns $ m \cdot \text{sign}(a) $, the largest integer such that $ m^n \leq |a| $, with the sign adjusted for signed integers.

Source§

impl Int<u8>

Available on crate feature _int_u8 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_u8).is_square(), false];
assert_eq![Int(13_u8).is_square(), false];
assert_eq![Int(16_u8).is_square(), true];
assert_eq![Int(20_u8).is_square(), false];
assert_eq![Int(21_u8).is_square(), false];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Int<u8>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u8).sqrt_ceil(), Int(4)];
assert_eq![Int(13_u8).sqrt_ceil(), Int(4)];
assert_eq![Int(16_u8).sqrt_ceil(), Int(4)];
assert_eq![Int(20_u8).sqrt_ceil(), Int(5)];
assert_eq![Int(21_u8).sqrt_ceil(), Int(5)];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Int<u8>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_u8).sqrt_floor(), Int(3)];
assert_eq![Int(13_u8).sqrt_floor(), Int(3)];
assert_eq![Int(16_u8).sqrt_floor(), Int(4)];
assert_eq![Int(20_u8).sqrt_floor(), Int(4)];
assert_eq![Int(21_u8).sqrt_floor(), Int(4)];
§Features

This will only be const if the _cmp_u8 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<u8>>

Returns the rounded integer square root.

Performs operations internally as u16.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u8).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_u8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_u8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_u8).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_u8).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<u8>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_u8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_u8).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_u8).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_u8).root_ceil(4), Ok(Int(4))];
assert_eq![Int(u8::MAX).root_ceil(1), Ok(Int(u8::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<u8>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u8).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_u8).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_u8).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_u8).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_u8).root_floor(4), Ok(Int(3))];
assert_eq![Int(u8::MAX).root_floor(1), Ok(Int(u8::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Source§

impl Int<u16>

Available on crate feature _int_u16 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_u16).is_square(), false];
assert_eq![Int(13_u16).is_square(), false];
assert_eq![Int(16_u16).is_square(), true];
assert_eq![Int(20_u16).is_square(), false];
assert_eq![Int(21_u16).is_square(), false];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Int<u16>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u16).sqrt_ceil(), Int(4)];
assert_eq![Int(13_u16).sqrt_ceil(), Int(4)];
assert_eq![Int(16_u16).sqrt_ceil(), Int(4)];
assert_eq![Int(20_u16).sqrt_ceil(), Int(5)];
assert_eq![Int(21_u16).sqrt_ceil(), Int(5)];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Int<u16>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_u16).sqrt_floor(), Int(3)];
assert_eq![Int(13_u16).sqrt_floor(), Int(3)];
assert_eq![Int(16_u16).sqrt_floor(), Int(4)];
assert_eq![Int(20_u16).sqrt_floor(), Int(4)];
assert_eq![Int(21_u16).sqrt_floor(), Int(4)];
§Features

This will only be const if the _cmp_u16 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<u16>>

Returns the rounded integer square root.

Performs operations internally as u32.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u16).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_u16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_u16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_u16).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_u16).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<u16>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_u16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_u16).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_u16).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_u16).root_ceil(4), Ok(Int(4))];
assert_eq![Int(u16::MAX).root_ceil(1), Ok(Int(u16::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<u16>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u16).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_u16).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_u16).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_u16).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_u16).root_floor(4), Ok(Int(3))];
assert_eq![Int(u16::MAX).root_floor(1), Ok(Int(u16::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Source§

impl Int<u32>

Available on crate feature _int_u32 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_u32).is_square(), false];
assert_eq![Int(13_u32).is_square(), false];
assert_eq![Int(16_u32).is_square(), true];
assert_eq![Int(20_u32).is_square(), false];
assert_eq![Int(21_u32).is_square(), false];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Int<u32>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u32).sqrt_ceil(), Int(4)];
assert_eq![Int(13_u32).sqrt_ceil(), Int(4)];
assert_eq![Int(16_u32).sqrt_ceil(), Int(4)];
assert_eq![Int(20_u32).sqrt_ceil(), Int(5)];
assert_eq![Int(21_u32).sqrt_ceil(), Int(5)];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Int<u32>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_u32).sqrt_floor(), Int(3)];
assert_eq![Int(13_u32).sqrt_floor(), Int(3)];
assert_eq![Int(16_u32).sqrt_floor(), Int(4)];
assert_eq![Int(20_u32).sqrt_floor(), Int(4)];
assert_eq![Int(21_u32).sqrt_floor(), Int(4)];
§Features

This will only be const if the _cmp_u32 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<u32>>

Returns the rounded integer square root.

Performs operations internally as u64.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u32).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_u32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_u32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_u32).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_u32).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<u32>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_u32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_u32).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_u32).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_u32).root_ceil(4), Ok(Int(4))];
assert_eq![Int(u32::MAX).root_ceil(1), Ok(Int(u32::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<u32>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u32).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_u32).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_u32).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_u32).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_u32).root_floor(4), Ok(Int(3))];
assert_eq![Int(u32::MAX).root_floor(1), Ok(Int(u32::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Source§

impl Int<u64>

Available on crate feature _int_u64 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_u64).is_square(), false];
assert_eq![Int(13_u64).is_square(), false];
assert_eq![Int(16_u64).is_square(), true];
assert_eq![Int(20_u64).is_square(), false];
assert_eq![Int(21_u64).is_square(), false];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Int<u64>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u64).sqrt_ceil(), Int(4)];
assert_eq![Int(13_u64).sqrt_ceil(), Int(4)];
assert_eq![Int(16_u64).sqrt_ceil(), Int(4)];
assert_eq![Int(20_u64).sqrt_ceil(), Int(5)];
assert_eq![Int(21_u64).sqrt_ceil(), Int(5)];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Int<u64>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_u64).sqrt_floor(), Int(3)];
assert_eq![Int(13_u64).sqrt_floor(), Int(3)];
assert_eq![Int(16_u64).sqrt_floor(), Int(4)];
assert_eq![Int(20_u64).sqrt_floor(), Int(4)];
assert_eq![Int(21_u64).sqrt_floor(), Int(4)];
§Features

This will only be const if the _cmp_u64 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<u64>>

Returns the rounded integer square root.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u64).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_u64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_u64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_u64).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_u64).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<u64>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_u64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_u64).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_u64).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_u64).root_ceil(4), Ok(Int(4))];
assert_eq![Int(u64::MAX).root_ceil(1), Ok(Int(u64::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<u64>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u64).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_u64).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_u64).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_u64).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_u64).root_floor(4), Ok(Int(3))];
assert_eq![Int(u64::MAX).root_floor(1), Ok(Int(u64::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Source§

impl Int<u128>

Available on crate feature _int_u128 only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_u128).is_square(), false];
assert_eq![Int(13_u128).is_square(), false];
assert_eq![Int(16_u128).is_square(), true];
assert_eq![Int(20_u128).is_square(), false];
assert_eq![Int(21_u128).is_square(), false];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn sqrt_ceil(self) -> Int<u128>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u128).sqrt_ceil(), Int(4)];
assert_eq![Int(13_u128).sqrt_ceil(), Int(4)];
assert_eq![Int(16_u128).sqrt_ceil(), Int(4)];
assert_eq![Int(20_u128).sqrt_ceil(), Int(5)];
assert_eq![Int(21_u128).sqrt_ceil(), Int(5)];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn sqrt_floor(self) -> Int<u128>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_u128).sqrt_floor(), Int(3)];
assert_eq![Int(13_u128).sqrt_floor(), Int(3)];
assert_eq![Int(16_u128).sqrt_floor(), Int(4)];
assert_eq![Int(20_u128).sqrt_floor(), Int(4)];
assert_eq![Int(21_u128).sqrt_floor(), Int(4)];
§Features

This will only be const if the _cmp_u128 feature is enabled.

Source

pub const fn sqrt_round(self) -> Result<Int<u128>>

Returns the rounded integer square root.

Performs operations internally as u128.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_u128).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_u128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_u128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_u128).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_u128).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<u128>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_u128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_u128).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_u128).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_u128).root_ceil(4), Ok(Int(4))];
assert_eq![Int(u128::MAX).root_ceil(1), Ok(Int(u128::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<u128>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_u128).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_u128).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_u128).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_u128).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_u128).root_floor(4), Ok(Int(3))];
assert_eq![Int(u128::MAX).root_floor(1), Ok(Int(u128::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Source§

impl Int<usize>

Available on crate feature _int_usize only.
Source

pub const fn is_square(self) -> bool

Returns true if it’s a perfect square, false otherwise.

§Formulation

$$ \large \text{is\textunderscore square}(a) = \begin{cases} \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a \end{cases} $$

§Examples
assert_eq![Int(12_usize).is_square(), false];
assert_eq![Int(13_usize).is_square(), false];
assert_eq![Int(16_usize).is_square(), true];
assert_eq![Int(20_usize).is_square(), false];
assert_eq![Int(21_usize).is_square(), false];
Source

pub const fn sqrt_ceil(self) -> Int<usize>

Returns the ceiled integer square root.

§Formulation

$$ \large \begin{align} \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } n^2 = a \cr n+1 & \text{if } n^2 < a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_usize).sqrt_ceil(), Int(4)];
assert_eq![Int(13_usize).sqrt_ceil(), Int(4)];
assert_eq![Int(16_usize).sqrt_ceil(), Int(4)];
assert_eq![Int(20_usize).sqrt_ceil(), Int(5)];
assert_eq![Int(21_usize).sqrt_ceil(), Int(5)];
Source

pub const fn sqrt_floor(self) -> Int<usize>

Returns the floored integer square root.

§Formulation

$$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$

Where $n_{k}$ is the result of a sequence of estimates that starts with an initial $n_{0} = a/2$ which is updated using Heron’s method:

$$ \large n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, \quad \small\text{for} \quad i = 0, 1, \ldots, k, $$

Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next estimate, $a$ is self, and $k$ is the number of iterations needed to converge to a solution, on the order of the number of bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would be $ ±7 $ iterations.

Hence, the function continues updating the estimate until reaching $n_{k}$, which provides the largest integer less than or equal to the square root of a.

§Examples
assert_eq![Int(12_usize).sqrt_floor(), Int(3)];
assert_eq![Int(13_usize).sqrt_floor(), Int(3)];
assert_eq![Int(16_usize).sqrt_floor(), Int(4)];
assert_eq![Int(20_usize).sqrt_floor(), Int(4)];
assert_eq![Int(21_usize).sqrt_floor(), Int(4)];
Source

pub const fn sqrt_round(self) -> Result<Int<usize>>

Returns the rounded integer square root.

Performs operations internally as usize_up.

§Features

Uses unsafe_hint for performance optimizations with upcasted arithmetic.

§Errors

Can returns Overflow if there’s no larger type to upcast and the value is close to its maximum.

§Formulation

$$ \begin{align} \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} n & \text{if } a - n^2 < (n+1)^2 - a \cr n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & \end{align} $$

§Examples
assert_eq![Int(12_usize).sqrt_round(), Ok(Int(3))];
assert_eq![Int(13_usize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(16_usize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(20_usize).sqrt_round(), Ok(Int(4))];
assert_eq![Int(21_usize).sqrt_round(), Ok(Int(5))];
Source

pub const fn root_ceil(self, nth: u32) -> Result<Int<usize>>

Returns the ceiled integer nth root.

$$ \large \left\lceil a^{\frac{1}{n}} \right\rceil = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_usize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(70_usize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(81_usize).root_ceil(4), Ok(Int(3))];
assert_eq![Int(88_usize).root_ceil(4), Ok(Int(4))];
assert_eq![Int(114_usize).root_ceil(4), Ok(Int(4))];
assert_eq![Int(usize::MAX).root_ceil(1), Ok(Int(usize::MAX))];
§Formulation
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \lfloor a^{\frac{1}{n}} \rfloor \cr \notag \left\lceil a^{\frac{1}{n}} \right\rceil = \begin{cases} m & \text{if } m^n = a, \cr m+1 & \text{if } m^n < a. \end{cases} \end{align} $$

§Algorithm

The algorithm computes the smallest integer $ m $ such that: $$ \large m^n \geq a. $$ It first computes the floored nth root $ \lfloor a^{\frac{1}{n}} \rfloor $ and then:

  1. Checks if $ \lfloor a^{\frac{1}{n}} \rfloor^n = a $.
  2. If true, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor $.
  3. Otherwise, returns $ m = \lfloor a^{\frac{1}{n}} \rfloor + 1 $.
Source

pub const fn root_floor(self, nth: u32) -> Result<Int<usize>>

Returns the floored integer nth root.

$$ \large \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $$

§Errors

Returns NonZeroRequired if nth is 0.

§Examples
assert_eq![Int(48_usize).root_floor(4), Ok(Int(2))];
assert_eq![Int(70_usize).root_floor(4), Ok(Int(2))];
assert_eq![Int(81_usize).root_floor(4), Ok(Int(3))];
assert_eq![Int(88_usize).root_floor(4), Ok(Int(3))];
assert_eq![Int(114_usize).root_floor(4), Ok(Int(3))];
assert_eq![Int(usize::MAX).root_floor(1), Ok(Int(usize::MAX))];
§Formulations
§Piece-wise

$$ \large \begin{align} \notag \text{If } n = 0, \text{ then error.} \cr \notag \text{If } n = 1, \text{ then output } a. \cr \notag \text{If } a = 0, \text{ then output } 0. \cr \notag m = \max { k \in \Z_{\geq 0} \mid k^n \leq a } \cr \notag \text{Output: } m & \end{align} $$

§Algorithm

The algorithm computes the floored nth root, $ \left\lfloor a^{\frac{1}{n}} \right\rfloor = m $, where $ m $ is the largest integer such that: $$ \large m^n \leq a. $$ It incrementally tests values starting from $ m = 1 $ and continues until the next value $ m+1 $ satisfies: $$ \large (m+1)^n > a. $$ The function then returns $ m $.

Trait Implementations§

Source§

impl<'s, 'o> Add<&'o Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i128>) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i128>) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i16>) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i16>) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i32>) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i32>) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i64>) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i64>) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i8>) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<i8>) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<isize>) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<isize>) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u128>) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u128>) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u16>) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u16>) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u32>) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u32>) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u64>) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u64>) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u8>) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<u8>) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<usize>) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o Int<usize>) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i128) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i128) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i16) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i16) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i32) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i32) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i64) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i64) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i8) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o i8) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o isize) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o isize) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u128) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u128) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u16) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u16) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u32) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u32) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u64) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u64) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u8) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o u8) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'s, 'o> Add<&'o usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o usize) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'o> Add<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'o usize) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i128>) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i16>) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i32>) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i64>) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i8>) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<isize>) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u128>) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u16>) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u32>) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u64>) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u8>) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'s> Add<Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<usize>) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'s> Add<i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: i128) -> Int<i128>

Performs the + operation. Read more
Source§

impl Add<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: i128) -> Int<i128>

Performs the + operation. Read more
Source§

impl<'s> Add<i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: i16) -> Int<i16>

Performs the + operation. Read more
Source§

impl Add<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: i16) -> Int<i16>

Performs the + operation. Read more
Source§

impl<'s> Add<i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: i32) -> Int<i32>

Performs the + operation. Read more
Source§

impl Add<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: i32) -> Int<i32>

Performs the + operation. Read more
Source§

impl<'s> Add<i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: i64) -> Int<i64>

Performs the + operation. Read more
Source§

impl Add<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: i64) -> Int<i64>

Performs the + operation. Read more
Source§

impl<'s> Add<i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: i8) -> Int<i8>

Performs the + operation. Read more
Source§

impl Add<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: i8) -> Int<i8>

Performs the + operation. Read more
Source§

impl<'s> Add<isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: isize) -> Int<isize>

Performs the + operation. Read more
Source§

impl Add<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: isize) -> Int<isize>

Performs the + operation. Read more
Source§

impl<'s> Add<u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: u128) -> Int<u128>

Performs the + operation. Read more
Source§

impl Add<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: u128) -> Int<u128>

Performs the + operation. Read more
Source§

impl<'s> Add<u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: u16) -> Int<u16>

Performs the + operation. Read more
Source§

impl Add<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: u16) -> Int<u16>

Performs the + operation. Read more
Source§

impl<'s> Add<u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: u32) -> Int<u32>

Performs the + operation. Read more
Source§

impl Add<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: u32) -> Int<u32>

Performs the + operation. Read more
Source§

impl<'s> Add<u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: u64) -> Int<u64>

Performs the + operation. Read more
Source§

impl Add<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: u64) -> Int<u64>

Performs the + operation. Read more
Source§

impl<'s> Add<u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: u8) -> Int<u8>

Performs the + operation. Read more
Source§

impl Add<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: u8) -> Int<u8>

Performs the + operation. Read more
Source§

impl<'s> Add<usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: usize) -> Int<usize>

Performs the + operation. Read more
Source§

impl Add<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: usize) -> Int<usize>

Performs the + operation. Read more
Source§

impl Add for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i128>) -> Int<i128>

Performs the + operation. Read more
Source§

impl Add for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i16>) -> Int<i16>

Performs the + operation. Read more
Source§

impl Add for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i32>) -> Int<i32>

Performs the + operation. Read more
Source§

impl Add for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i64>) -> Int<i64>

Performs the + operation. Read more
Source§

impl Add for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<i8>) -> Int<i8>

Performs the + operation. Read more
Source§

impl Add for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<isize>) -> Int<isize>

Performs the + operation. Read more
Source§

impl Add for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u128>) -> Int<u128>

Performs the + operation. Read more
Source§

impl Add for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u16>) -> Int<u16>

Performs the + operation. Read more
Source§

impl Add for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u32>) -> Int<u32>

Performs the + operation. Read more
Source§

impl Add for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u64>) -> Int<u64>

Performs the + operation. Read more
Source§

impl Add for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<u8>) -> Int<u8>

Performs the + operation. Read more
Source§

impl Add for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the + operator.
Source§

fn add(self, other: Int<usize>) -> Int<usize>

Performs the + operation. Read more
Source§

impl<'o> AddAssign<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn add_assign(&mut self, other: &'o Int<i128>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn add_assign(&mut self, other: &'o Int<i16>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn add_assign(&mut self, other: &'o Int<i32>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn add_assign(&mut self, other: &'o Int<i64>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: &'o Int<i8>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn add_assign(&mut self, other: &'o Int<isize>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn add_assign(&mut self, other: &'o Int<u128>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn add_assign(&mut self, other: &'o Int<u16>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn add_assign(&mut self, other: &'o Int<u32>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn add_assign(&mut self, other: &'o Int<u64>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: &'o Int<u8>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn add_assign(&mut self, other: &'o Int<usize>)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn add_assign(&mut self, other: &'o i128)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn add_assign(&mut self, other: &'o i16)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn add_assign(&mut self, other: &'o i32)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn add_assign(&mut self, other: &'o i64)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: &'o i8)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn add_assign(&mut self, other: &'o isize)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn add_assign(&mut self, other: &'o u128)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn add_assign(&mut self, other: &'o u16)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn add_assign(&mut self, other: &'o u32)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn add_assign(&mut self, other: &'o u64)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: &'o u8)

Performs the += operation. Read more
Source§

impl<'o> AddAssign<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn add_assign(&mut self, other: &'o usize)

Performs the += operation. Read more
Source§

impl AddAssign<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn add_assign(&mut self, other: i128)

Performs the += operation. Read more
Source§

impl AddAssign<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn add_assign(&mut self, other: i16)

Performs the += operation. Read more
Source§

impl AddAssign<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn add_assign(&mut self, other: i32)

Performs the += operation. Read more
Source§

impl AddAssign<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn add_assign(&mut self, other: i64)

Performs the += operation. Read more
Source§

impl AddAssign<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: i8)

Performs the += operation. Read more
Source§

impl AddAssign<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn add_assign(&mut self, other: isize)

Performs the += operation. Read more
Source§

impl AddAssign<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn add_assign(&mut self, other: u128)

Performs the += operation. Read more
Source§

impl AddAssign<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn add_assign(&mut self, other: u16)

Performs the += operation. Read more
Source§

impl AddAssign<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn add_assign(&mut self, other: u32)

Performs the += operation. Read more
Source§

impl AddAssign<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn add_assign(&mut self, other: u64)

Performs the += operation. Read more
Source§

impl AddAssign<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: u8)

Performs the += operation. Read more
Source§

impl AddAssign<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn add_assign(&mut self, other: usize)

Performs the += operation. Read more
Source§

impl AddAssign for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn add_assign(&mut self, other: Int<i128>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn add_assign(&mut self, other: Int<i16>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn add_assign(&mut self, other: Int<i32>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn add_assign(&mut self, other: Int<i64>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: Int<i8>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<isize>

Available on crate feature _int_isize only.
Source§

fn add_assign(&mut self, other: Int<isize>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn add_assign(&mut self, other: Int<u128>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn add_assign(&mut self, other: Int<u16>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn add_assign(&mut self, other: Int<u32>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn add_assign(&mut self, other: Int<u64>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn add_assign(&mut self, other: Int<u8>)

Performs the += operation. Read more
Source§

impl AddAssign for Int<usize>

Available on crate feature _int_usize only.
Source§

fn add_assign(&mut self, other: Int<usize>)

Performs the += operation. Read more
Source§

impl<T: Binary> Binary for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone> Clone for Int<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Display> Display for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'s, 'o> Div<&'o Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i128>) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i128>) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i16>) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i16>) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i32>) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i32>) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i64>) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i64>) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i8>) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<i8>) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<isize>) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<isize>) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u128>) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u128>) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u16>) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u16>) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u32>) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u32>) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u64>) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u64>) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u8>) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<u8>) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<usize>) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o Int<usize>) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i128) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i128) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i16) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i16) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i32) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i32) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i64) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i64) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i8) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o i8) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o isize) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o isize) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u128) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u128) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u16) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u16) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u32) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u32) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u64) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u64) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u8) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o u8) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'s, 'o> Div<&'o usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o usize) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'o> Div<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'o usize) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i128>) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i16>) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i32>) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i64>) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i8>) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<isize>) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u128>) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u16>) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u32>) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u64>) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u8>) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'s> Div<Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<usize>) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'s> Div<i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: i128) -> Int<i128>

Performs the / operation. Read more
Source§

impl Div<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: i128) -> Int<i128>

Performs the / operation. Read more
Source§

impl<'s> Div<i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: i16) -> Int<i16>

Performs the / operation. Read more
Source§

impl Div<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: i16) -> Int<i16>

Performs the / operation. Read more
Source§

impl<'s> Div<i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: i32) -> Int<i32>

Performs the / operation. Read more
Source§

impl Div<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: i32) -> Int<i32>

Performs the / operation. Read more
Source§

impl<'s> Div<i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: i64) -> Int<i64>

Performs the / operation. Read more
Source§

impl Div<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: i64) -> Int<i64>

Performs the / operation. Read more
Source§

impl<'s> Div<i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: i8) -> Int<i8>

Performs the / operation. Read more
Source§

impl Div<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: i8) -> Int<i8>

Performs the / operation. Read more
Source§

impl<'s> Div<isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: isize) -> Int<isize>

Performs the / operation. Read more
Source§

impl Div<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: isize) -> Int<isize>

Performs the / operation. Read more
Source§

impl<'s> Div<u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: u128) -> Int<u128>

Performs the / operation. Read more
Source§

impl Div<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: u128) -> Int<u128>

Performs the / operation. Read more
Source§

impl<'s> Div<u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: u16) -> Int<u16>

Performs the / operation. Read more
Source§

impl Div<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: u16) -> Int<u16>

Performs the / operation. Read more
Source§

impl<'s> Div<u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: u32) -> Int<u32>

Performs the / operation. Read more
Source§

impl Div<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: u32) -> Int<u32>

Performs the / operation. Read more
Source§

impl<'s> Div<u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: u64) -> Int<u64>

Performs the / operation. Read more
Source§

impl Div<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: u64) -> Int<u64>

Performs the / operation. Read more
Source§

impl<'s> Div<u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: u8) -> Int<u8>

Performs the / operation. Read more
Source§

impl Div<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: u8) -> Int<u8>

Performs the / operation. Read more
Source§

impl<'s> Div<usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: usize) -> Int<usize>

Performs the / operation. Read more
Source§

impl Div<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: usize) -> Int<usize>

Performs the / operation. Read more
Source§

impl Div for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i128>) -> Int<i128>

Performs the / operation. Read more
Source§

impl Div for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i16>) -> Int<i16>

Performs the / operation. Read more
Source§

impl Div for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i32>) -> Int<i32>

Performs the / operation. Read more
Source§

impl Div for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i64>) -> Int<i64>

Performs the / operation. Read more
Source§

impl Div for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<i8>) -> Int<i8>

Performs the / operation. Read more
Source§

impl Div for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<isize>) -> Int<isize>

Performs the / operation. Read more
Source§

impl Div for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u128>) -> Int<u128>

Performs the / operation. Read more
Source§

impl Div for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u16>) -> Int<u16>

Performs the / operation. Read more
Source§

impl Div for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u32>) -> Int<u32>

Performs the / operation. Read more
Source§

impl Div for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u64>) -> Int<u64>

Performs the / operation. Read more
Source§

impl Div for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<u8>) -> Int<u8>

Performs the / operation. Read more
Source§

impl Div for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Int<usize>) -> Int<usize>

Performs the / operation. Read more
Source§

impl<'o> DivAssign<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn div_assign(&mut self, other: &'o Int<i128>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn div_assign(&mut self, other: &'o Int<i16>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn div_assign(&mut self, other: &'o Int<i32>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn div_assign(&mut self, other: &'o Int<i64>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: &'o Int<i8>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn div_assign(&mut self, other: &'o Int<isize>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn div_assign(&mut self, other: &'o Int<u128>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn div_assign(&mut self, other: &'o Int<u16>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn div_assign(&mut self, other: &'o Int<u32>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn div_assign(&mut self, other: &'o Int<u64>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: &'o Int<u8>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn div_assign(&mut self, other: &'o Int<usize>)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn div_assign(&mut self, other: &'o i128)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn div_assign(&mut self, other: &'o i16)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn div_assign(&mut self, other: &'o i32)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn div_assign(&mut self, other: &'o i64)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: &'o i8)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn div_assign(&mut self, other: &'o isize)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn div_assign(&mut self, other: &'o u128)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn div_assign(&mut self, other: &'o u16)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn div_assign(&mut self, other: &'o u32)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn div_assign(&mut self, other: &'o u64)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: &'o u8)

Performs the /= operation. Read more
Source§

impl<'o> DivAssign<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn div_assign(&mut self, other: &'o usize)

Performs the /= operation. Read more
Source§

impl DivAssign<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn div_assign(&mut self, other: i128)

Performs the /= operation. Read more
Source§

impl DivAssign<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn div_assign(&mut self, other: i16)

Performs the /= operation. Read more
Source§

impl DivAssign<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn div_assign(&mut self, other: i32)

Performs the /= operation. Read more
Source§

impl DivAssign<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn div_assign(&mut self, other: i64)

Performs the /= operation. Read more
Source§

impl DivAssign<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: i8)

Performs the /= operation. Read more
Source§

impl DivAssign<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn div_assign(&mut self, other: isize)

Performs the /= operation. Read more
Source§

impl DivAssign<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn div_assign(&mut self, other: u128)

Performs the /= operation. Read more
Source§

impl DivAssign<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn div_assign(&mut self, other: u16)

Performs the /= operation. Read more
Source§

impl DivAssign<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
Source§

impl DivAssign<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn div_assign(&mut self, other: u64)

Performs the /= operation. Read more
Source§

impl DivAssign<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: u8)

Performs the /= operation. Read more
Source§

impl DivAssign<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn div_assign(&mut self, other: usize)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn div_assign(&mut self, other: Int<i128>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn div_assign(&mut self, other: Int<i16>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn div_assign(&mut self, other: Int<i32>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn div_assign(&mut self, other: Int<i64>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: Int<i8>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<isize>

Available on crate feature _int_isize only.
Source§

fn div_assign(&mut self, other: Int<isize>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn div_assign(&mut self, other: Int<u128>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn div_assign(&mut self, other: Int<u16>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn div_assign(&mut self, other: Int<u32>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn div_assign(&mut self, other: Int<u64>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn div_assign(&mut self, other: Int<u8>)

Performs the /= operation. Read more
Source§

impl DivAssign for Int<usize>

Available on crate feature _int_usize only.
Source§

fn div_assign(&mut self, other: Int<usize>)

Performs the /= operation. Read more
Source§

impl<T: Hash> Hash for Int<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Hasher> Hasher for Int<T>

Source§

fn finish(&self) -> u64

Returns the hash value for the values written so far. Read more
Source§

fn write(&mut self, bytes: &[u8])

Writes some data into this Hasher. Read more
1.3.0 · Source§

fn write_u8(&mut self, i: u8)

Writes a single u8 into this hasher.
1.3.0 · Source§

fn write_u16(&mut self, i: u16)

Writes a single u16 into this hasher.
1.3.0 · Source§

fn write_u32(&mut self, i: u32)

Writes a single u32 into this hasher.
1.3.0 · Source§

fn write_u64(&mut self, i: u64)

Writes a single u64 into this hasher.
1.26.0 · Source§

fn write_u128(&mut self, i: u128)

Writes a single u128 into this hasher.
1.3.0 · Source§

fn write_usize(&mut self, i: usize)

Writes a single usize into this hasher.
1.3.0 · Source§

fn write_i8(&mut self, i: i8)

Writes a single i8 into this hasher.
1.3.0 · Source§

fn write_i16(&mut self, i: i16)

Writes a single i16 into this hasher.
1.3.0 · Source§

fn write_i32(&mut self, i: i32)

Writes a single i32 into this hasher.
1.3.0 · Source§

fn write_i64(&mut self, i: i64)

Writes a single i64 into this hasher.
1.26.0 · Source§

fn write_i128(&mut self, i: i128)

Writes a single i128 into this hasher.
1.3.0 · Source§

fn write_isize(&mut self, i: isize)

Writes a single isize into this hasher.
Source§

fn write_length_prefix(&mut self, len: usize)

🔬This is a nightly-only experimental API. (hasher_prefixfree_extras)
Writes a length prefix into this hasher, as part of being prefix-free. Read more
Source§

fn write_str(&mut self, s: &str)

🔬This is a nightly-only experimental API. (hasher_prefixfree_extras)
Writes a single str into this hasher. Read more
Source§

impl<T: LowerExp> LowerExp for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: LowerHex> LowerHex for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'s, 'o> Mul<&'o Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i128>) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i128>) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i16>) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i16>) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i32>) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i32>) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i64>) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i64>) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i8>) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<i8>) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<isize>) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<isize>) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u128>) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u128>) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u16>) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u16>) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u32>) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u32>) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u64>) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u64>) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u8>) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<u8>) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<usize>) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o Int<usize>) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i128) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i128) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i16) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i16) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i32) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i32) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i64) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i64) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i8) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o i8) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o isize) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o isize) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u128) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u128) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u16) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u16) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u32) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u32) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u64) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u64) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u8) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o u8) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'s, 'o> Mul<&'o usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o usize) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'o> Mul<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'o usize) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i128>) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i16>) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i32>) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i64>) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i8>) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<isize>) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u128>) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u16>) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u32>) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u64>) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u8>) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'s> Mul<Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<usize>) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'s> Mul<i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i128) -> Int<i128>

Performs the * operation. Read more
Source§

impl Mul<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i128) -> Int<i128>

Performs the * operation. Read more
Source§

impl<'s> Mul<i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i16) -> Int<i16>

Performs the * operation. Read more
Source§

impl Mul<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i16) -> Int<i16>

Performs the * operation. Read more
Source§

impl<'s> Mul<i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i32) -> Int<i32>

Performs the * operation. Read more
Source§

impl Mul<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i32) -> Int<i32>

Performs the * operation. Read more
Source§

impl<'s> Mul<i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i64) -> Int<i64>

Performs the * operation. Read more
Source§

impl Mul<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i64) -> Int<i64>

Performs the * operation. Read more
Source§

impl<'s> Mul<i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i8) -> Int<i8>

Performs the * operation. Read more
Source§

impl Mul<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i8) -> Int<i8>

Performs the * operation. Read more
Source§

impl<'s> Mul<isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: isize) -> Int<isize>

Performs the * operation. Read more
Source§

impl Mul<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: isize) -> Int<isize>

Performs the * operation. Read more
Source§

impl<'s> Mul<u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u128) -> Int<u128>

Performs the * operation. Read more
Source§

impl Mul<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u128) -> Int<u128>

Performs the * operation. Read more
Source§

impl<'s> Mul<u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u16) -> Int<u16>

Performs the * operation. Read more
Source§

impl Mul<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u16) -> Int<u16>

Performs the * operation. Read more
Source§

impl<'s> Mul<u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u32) -> Int<u32>

Performs the * operation. Read more
Source§

impl Mul<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u32) -> Int<u32>

Performs the * operation. Read more
Source§

impl<'s> Mul<u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u64) -> Int<u64>

Performs the * operation. Read more
Source§

impl Mul<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u64) -> Int<u64>

Performs the * operation. Read more
Source§

impl<'s> Mul<u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u8) -> Int<u8>

Performs the * operation. Read more
Source§

impl Mul<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u8) -> Int<u8>

Performs the * operation. Read more
Source§

impl<'s> Mul<usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: usize) -> Int<usize>

Performs the * operation. Read more
Source§

impl Mul<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: usize) -> Int<usize>

Performs the * operation. Read more
Source§

impl Mul for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i128>) -> Int<i128>

Performs the * operation. Read more
Source§

impl Mul for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i16>) -> Int<i16>

Performs the * operation. Read more
Source§

impl Mul for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i32>) -> Int<i32>

Performs the * operation. Read more
Source§

impl Mul for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i64>) -> Int<i64>

Performs the * operation. Read more
Source§

impl Mul for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<i8>) -> Int<i8>

Performs the * operation. Read more
Source§

impl Mul for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<isize>) -> Int<isize>

Performs the * operation. Read more
Source§

impl Mul for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u128>) -> Int<u128>

Performs the * operation. Read more
Source§

impl Mul for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u16>) -> Int<u16>

Performs the * operation. Read more
Source§

impl Mul for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u32>) -> Int<u32>

Performs the * operation. Read more
Source§

impl Mul for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u64>) -> Int<u64>

Performs the * operation. Read more
Source§

impl Mul for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<u8>) -> Int<u8>

Performs the * operation. Read more
Source§

impl Mul for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Int<usize>) -> Int<usize>

Performs the * operation. Read more
Source§

impl<'o> MulAssign<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn mul_assign(&mut self, other: &'o Int<i128>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn mul_assign(&mut self, other: &'o Int<i16>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn mul_assign(&mut self, other: &'o Int<i32>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn mul_assign(&mut self, other: &'o Int<i64>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: &'o Int<i8>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn mul_assign(&mut self, other: &'o Int<isize>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn mul_assign(&mut self, other: &'o Int<u128>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn mul_assign(&mut self, other: &'o Int<u16>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn mul_assign(&mut self, other: &'o Int<u32>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn mul_assign(&mut self, other: &'o Int<u64>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: &'o Int<u8>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn mul_assign(&mut self, other: &'o Int<usize>)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn mul_assign(&mut self, other: &'o i128)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn mul_assign(&mut self, other: &'o i16)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn mul_assign(&mut self, other: &'o i32)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn mul_assign(&mut self, other: &'o i64)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: &'o i8)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn mul_assign(&mut self, other: &'o isize)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn mul_assign(&mut self, other: &'o u128)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn mul_assign(&mut self, other: &'o u16)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn mul_assign(&mut self, other: &'o u32)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn mul_assign(&mut self, other: &'o u64)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: &'o u8)

Performs the *= operation. Read more
Source§

impl<'o> MulAssign<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn mul_assign(&mut self, other: &'o usize)

Performs the *= operation. Read more
Source§

impl MulAssign<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn mul_assign(&mut self, other: i128)

Performs the *= operation. Read more
Source§

impl MulAssign<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn mul_assign(&mut self, other: i16)

Performs the *= operation. Read more
Source§

impl MulAssign<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn mul_assign(&mut self, other: i32)

Performs the *= operation. Read more
Source§

impl MulAssign<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn mul_assign(&mut self, other: i64)

Performs the *= operation. Read more
Source§

impl MulAssign<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: i8)

Performs the *= operation. Read more
Source§

impl MulAssign<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn mul_assign(&mut self, other: isize)

Performs the *= operation. Read more
Source§

impl MulAssign<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn mul_assign(&mut self, other: u128)

Performs the *= operation. Read more
Source§

impl MulAssign<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn mul_assign(&mut self, other: u16)

Performs the *= operation. Read more
Source§

impl MulAssign<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
Source§

impl MulAssign<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn mul_assign(&mut self, other: u64)

Performs the *= operation. Read more
Source§

impl MulAssign<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: u8)

Performs the *= operation. Read more
Source§

impl MulAssign<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn mul_assign(&mut self, other: usize)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn mul_assign(&mut self, other: Int<i128>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn mul_assign(&mut self, other: Int<i16>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn mul_assign(&mut self, other: Int<i32>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn mul_assign(&mut self, other: Int<i64>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: Int<i8>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<isize>

Available on crate feature _int_isize only.
Source§

fn mul_assign(&mut self, other: Int<isize>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn mul_assign(&mut self, other: Int<u128>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn mul_assign(&mut self, other: Int<u16>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn mul_assign(&mut self, other: Int<u32>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn mul_assign(&mut self, other: Int<u64>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn mul_assign(&mut self, other: Int<u8>)

Performs the *= operation. Read more
Source§

impl MulAssign for Int<usize>

Available on crate feature _int_usize only.
Source§

fn mul_assign(&mut self, other: Int<usize>)

Performs the *= operation. Read more
Source§

impl Neg for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<i128>

Performs the unary - operation. Read more
Source§

impl Neg for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<i16>

Performs the unary - operation. Read more
Source§

impl Neg for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<i32>

Performs the unary - operation. Read more
Source§

impl Neg for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<i64>

Performs the unary - operation. Read more
Source§

impl Neg for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<i8>

Performs the unary - operation. Read more
Source§

impl Neg for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Int<isize>

Performs the unary - operation. Read more
Source§

impl<T: Octal> Octal for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Ord> Ord for Int<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq<T> for Int<T>

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq> PartialEq for Int<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd<T> for Int<T>

Source§

fn partial_cmp(&self, other: &T) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialOrd> PartialOrd for Int<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'s, 'o> Rem<&'o Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i128>) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i128>) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i16>) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i16>) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i32>) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i32>) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i64>) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i64>) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i8>) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<i8>) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<isize>) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<isize>) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u128>) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u128>) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u16>) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u16>) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u32>) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u32>) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u64>) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u64>) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u8>) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<u8>) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<usize>) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o Int<usize>) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i128) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i128) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i16) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i16) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i32) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i32) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i64) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i64) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i8) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o i8) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o isize) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o isize) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u128) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u128) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u16) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u16) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u32) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u32) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u64) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u64) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u8) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o u8) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'s, 'o> Rem<&'o usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o usize) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'o> Rem<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: &'o usize) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i128>) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i16>) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i32>) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i64>) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i8>) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<isize>) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u128>) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u16>) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u32>) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u64>) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u8>) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'s> Rem<Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<usize>) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'s> Rem<i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i128) -> Int<i128>

Performs the % operation. Read more
Source§

impl Rem<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i128) -> Int<i128>

Performs the % operation. Read more
Source§

impl<'s> Rem<i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i16) -> Int<i16>

Performs the % operation. Read more
Source§

impl Rem<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i16) -> Int<i16>

Performs the % operation. Read more
Source§

impl<'s> Rem<i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i32) -> Int<i32>

Performs the % operation. Read more
Source§

impl Rem<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i32) -> Int<i32>

Performs the % operation. Read more
Source§

impl<'s> Rem<i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i64) -> Int<i64>

Performs the % operation. Read more
Source§

impl Rem<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i64) -> Int<i64>

Performs the % operation. Read more
Source§

impl<'s> Rem<i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i8) -> Int<i8>

Performs the % operation. Read more
Source§

impl Rem<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: i8) -> Int<i8>

Performs the % operation. Read more
Source§

impl<'s> Rem<isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: isize) -> Int<isize>

Performs the % operation. Read more
Source§

impl Rem<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: isize) -> Int<isize>

Performs the % operation. Read more
Source§

impl<'s> Rem<u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u128) -> Int<u128>

Performs the % operation. Read more
Source§

impl Rem<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u128) -> Int<u128>

Performs the % operation. Read more
Source§

impl<'s> Rem<u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u16) -> Int<u16>

Performs the % operation. Read more
Source§

impl Rem<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u16) -> Int<u16>

Performs the % operation. Read more
Source§

impl<'s> Rem<u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u32) -> Int<u32>

Performs the % operation. Read more
Source§

impl Rem<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u32) -> Int<u32>

Performs the % operation. Read more
Source§

impl<'s> Rem<u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u64) -> Int<u64>

Performs the % operation. Read more
Source§

impl Rem<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u64) -> Int<u64>

Performs the % operation. Read more
Source§

impl<'s> Rem<u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u8) -> Int<u8>

Performs the % operation. Read more
Source§

impl Rem<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: u8) -> Int<u8>

Performs the % operation. Read more
Source§

impl<'s> Rem<usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: usize) -> Int<usize>

Performs the % operation. Read more
Source§

impl Rem<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: usize) -> Int<usize>

Performs the % operation. Read more
Source§

impl Rem for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i128>) -> Int<i128>

Performs the % operation. Read more
Source§

impl Rem for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i16>) -> Int<i16>

Performs the % operation. Read more
Source§

impl Rem for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i32>) -> Int<i32>

Performs the % operation. Read more
Source§

impl Rem for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i64>) -> Int<i64>

Performs the % operation. Read more
Source§

impl Rem for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<i8>) -> Int<i8>

Performs the % operation. Read more
Source§

impl Rem for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<isize>) -> Int<isize>

Performs the % operation. Read more
Source§

impl Rem for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u128>) -> Int<u128>

Performs the % operation. Read more
Source§

impl Rem for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u16>) -> Int<u16>

Performs the % operation. Read more
Source§

impl Rem for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u32>) -> Int<u32>

Performs the % operation. Read more
Source§

impl Rem for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u64>) -> Int<u64>

Performs the % operation. Read more
Source§

impl Rem for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<u8>) -> Int<u8>

Performs the % operation. Read more
Source§

impl Rem for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Int<usize>) -> Int<usize>

Performs the % operation. Read more
Source§

impl<'o> RemAssign<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn rem_assign(&mut self, other: &'o Int<i128>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn rem_assign(&mut self, other: &'o Int<i16>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn rem_assign(&mut self, other: &'o Int<i32>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn rem_assign(&mut self, other: &'o Int<i64>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: &'o Int<i8>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn rem_assign(&mut self, other: &'o Int<isize>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn rem_assign(&mut self, other: &'o Int<u128>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn rem_assign(&mut self, other: &'o Int<u16>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn rem_assign(&mut self, other: &'o Int<u32>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn rem_assign(&mut self, other: &'o Int<u64>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: &'o Int<u8>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn rem_assign(&mut self, other: &'o Int<usize>)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn rem_assign(&mut self, other: &'o i128)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn rem_assign(&mut self, other: &'o i16)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn rem_assign(&mut self, other: &'o i32)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn rem_assign(&mut self, other: &'o i64)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: &'o i8)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn rem_assign(&mut self, other: &'o isize)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn rem_assign(&mut self, other: &'o u128)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn rem_assign(&mut self, other: &'o u16)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn rem_assign(&mut self, other: &'o u32)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn rem_assign(&mut self, other: &'o u64)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: &'o u8)

Performs the %= operation. Read more
Source§

impl<'o> RemAssign<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn rem_assign(&mut self, other: &'o usize)

Performs the %= operation. Read more
Source§

impl RemAssign<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn rem_assign(&mut self, other: i128)

Performs the %= operation. Read more
Source§

impl RemAssign<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn rem_assign(&mut self, other: i16)

Performs the %= operation. Read more
Source§

impl RemAssign<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn rem_assign(&mut self, other: i32)

Performs the %= operation. Read more
Source§

impl RemAssign<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn rem_assign(&mut self, other: i64)

Performs the %= operation. Read more
Source§

impl RemAssign<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: i8)

Performs the %= operation. Read more
Source§

impl RemAssign<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn rem_assign(&mut self, other: isize)

Performs the %= operation. Read more
Source§

impl RemAssign<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn rem_assign(&mut self, other: u128)

Performs the %= operation. Read more
Source§

impl RemAssign<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn rem_assign(&mut self, other: u16)

Performs the %= operation. Read more
Source§

impl RemAssign<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn rem_assign(&mut self, other: u32)

Performs the %= operation. Read more
Source§

impl RemAssign<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn rem_assign(&mut self, other: u64)

Performs the %= operation. Read more
Source§

impl RemAssign<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: u8)

Performs the %= operation. Read more
Source§

impl RemAssign<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn rem_assign(&mut self, other: usize)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn rem_assign(&mut self, other: Int<i128>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn rem_assign(&mut self, other: Int<i16>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn rem_assign(&mut self, other: Int<i32>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn rem_assign(&mut self, other: Int<i64>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: Int<i8>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<isize>

Available on crate feature _int_isize only.
Source§

fn rem_assign(&mut self, other: Int<isize>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn rem_assign(&mut self, other: Int<u128>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn rem_assign(&mut self, other: Int<u16>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn rem_assign(&mut self, other: Int<u32>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn rem_assign(&mut self, other: Int<u64>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn rem_assign(&mut self, other: Int<u8>)

Performs the %= operation. Read more
Source§

impl RemAssign for Int<usize>

Available on crate feature _int_usize only.
Source§

fn rem_assign(&mut self, other: Int<usize>)

Performs the %= operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i128>) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i128>) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i16>) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i16>) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i32>) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i32>) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i64>) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i64>) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i8>) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<i8>) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<isize>) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<isize>) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u128>) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u128>) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u16>) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u16>) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u32>) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u32>) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u64>) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u64>) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u8>) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<u8>) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<usize>) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o Int<usize>) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i128) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i128) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i16) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i16) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i32) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i32) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i64) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i64) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i8) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o i8) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o isize) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o isize) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u128) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u128) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u16) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u16) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u32) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u32) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u64) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u64) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u8) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o u8) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'s, 'o> Sub<&'o usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o usize) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'o> Sub<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'o usize) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<i128>> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i128>) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<i16>> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i16>) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<i32>> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i32>) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<i64>> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i64>) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<i8>> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i8>) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<isize>> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<isize>) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<u128>> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u128>) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<u16>> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u16>) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<u32>> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u32>) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<u64>> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u64>) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<u8>> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u8>) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'s> Sub<Int<usize>> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<usize>) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'s> Sub<i128> for &'s Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i128) -> Int<i128>

Performs the - operation. Read more
Source§

impl Sub<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i128) -> Int<i128>

Performs the - operation. Read more
Source§

impl<'s> Sub<i16> for &'s Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i16) -> Int<i16>

Performs the - operation. Read more
Source§

impl Sub<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i16) -> Int<i16>

Performs the - operation. Read more
Source§

impl<'s> Sub<i32> for &'s Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i32) -> Int<i32>

Performs the - operation. Read more
Source§

impl Sub<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i32) -> Int<i32>

Performs the - operation. Read more
Source§

impl<'s> Sub<i64> for &'s Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i64) -> Int<i64>

Performs the - operation. Read more
Source§

impl Sub<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i64) -> Int<i64>

Performs the - operation. Read more
Source§

impl<'s> Sub<i8> for &'s Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i8) -> Int<i8>

Performs the - operation. Read more
Source§

impl Sub<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i8) -> Int<i8>

Performs the - operation. Read more
Source§

impl<'s> Sub<isize> for &'s Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: isize) -> Int<isize>

Performs the - operation. Read more
Source§

impl Sub<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: isize) -> Int<isize>

Performs the - operation. Read more
Source§

impl<'s> Sub<u128> for &'s Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u128) -> Int<u128>

Performs the - operation. Read more
Source§

impl Sub<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u128) -> Int<u128>

Performs the - operation. Read more
Source§

impl<'s> Sub<u16> for &'s Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u16) -> Int<u16>

Performs the - operation. Read more
Source§

impl Sub<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u16) -> Int<u16>

Performs the - operation. Read more
Source§

impl<'s> Sub<u32> for &'s Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u32) -> Int<u32>

Performs the - operation. Read more
Source§

impl Sub<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u32) -> Int<u32>

Performs the - operation. Read more
Source§

impl<'s> Sub<u64> for &'s Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u64) -> Int<u64>

Performs the - operation. Read more
Source§

impl Sub<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u64) -> Int<u64>

Performs the - operation. Read more
Source§

impl<'s> Sub<u8> for &'s Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u8) -> Int<u8>

Performs the - operation. Read more
Source§

impl Sub<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u8) -> Int<u8>

Performs the - operation. Read more
Source§

impl<'s> Sub<usize> for &'s Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: usize) -> Int<usize>

Performs the - operation. Read more
Source§

impl Sub<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: usize) -> Int<usize>

Performs the - operation. Read more
Source§

impl Sub for Int<i128>

Available on crate feature _int_i128 only.
Source§

type Output = Int<i128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i128>) -> Int<i128>

Performs the - operation. Read more
Source§

impl Sub for Int<i16>

Available on crate feature _int_i16 only.
Source§

type Output = Int<i16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i16>) -> Int<i16>

Performs the - operation. Read more
Source§

impl Sub for Int<i32>

Available on crate feature _int_i32 only.
Source§

type Output = Int<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i32>) -> Int<i32>

Performs the - operation. Read more
Source§

impl Sub for Int<i64>

Available on crate feature _int_i64 only.
Source§

type Output = Int<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i64>) -> Int<i64>

Performs the - operation. Read more
Source§

impl Sub for Int<i8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<i8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<i8>) -> Int<i8>

Performs the - operation. Read more
Source§

impl Sub for Int<isize>

Available on crate feature _int_isize only.
Source§

type Output = Int<isize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<isize>) -> Int<isize>

Performs the - operation. Read more
Source§

impl Sub for Int<u128>

Available on crate feature _int_u128 only.
Source§

type Output = Int<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u128>) -> Int<u128>

Performs the - operation. Read more
Source§

impl Sub for Int<u16>

Available on crate feature _int_u16 only.
Source§

type Output = Int<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u16>) -> Int<u16>

Performs the - operation. Read more
Source§

impl Sub for Int<u32>

Available on crate feature _int_u32 only.
Source§

type Output = Int<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u32>) -> Int<u32>

Performs the - operation. Read more
Source§

impl Sub for Int<u64>

Available on crate feature _int_u64 only.
Source§

type Output = Int<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u64>) -> Int<u64>

Performs the - operation. Read more
Source§

impl Sub for Int<u8>

Available on crate feature _int_i8 only.
Source§

type Output = Int<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<u8>) -> Int<u8>

Performs the - operation. Read more
Source§

impl Sub for Int<usize>

Available on crate feature _int_usize only.
Source§

type Output = Int<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Int<usize>) -> Int<usize>

Performs the - operation. Read more
Source§

impl<'o> SubAssign<&'o Int<i128>> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn sub_assign(&mut self, other: &'o Int<i128>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<i16>> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn sub_assign(&mut self, other: &'o Int<i16>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<i32>> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn sub_assign(&mut self, other: &'o Int<i32>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<i64>> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn sub_assign(&mut self, other: &'o Int<i64>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<i8>> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: &'o Int<i8>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<isize>> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn sub_assign(&mut self, other: &'o Int<isize>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<u128>> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn sub_assign(&mut self, other: &'o Int<u128>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<u16>> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn sub_assign(&mut self, other: &'o Int<u16>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<u32>> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn sub_assign(&mut self, other: &'o Int<u32>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<u64>> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn sub_assign(&mut self, other: &'o Int<u64>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<u8>> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: &'o Int<u8>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o Int<usize>> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn sub_assign(&mut self, other: &'o Int<usize>)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn sub_assign(&mut self, other: &'o i128)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn sub_assign(&mut self, other: &'o i16)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn sub_assign(&mut self, other: &'o i32)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn sub_assign(&mut self, other: &'o i64)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: &'o i8)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn sub_assign(&mut self, other: &'o isize)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn sub_assign(&mut self, other: &'o u128)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn sub_assign(&mut self, other: &'o u16)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn sub_assign(&mut self, other: &'o u32)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn sub_assign(&mut self, other: &'o u64)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: &'o u8)

Performs the -= operation. Read more
Source§

impl<'o> SubAssign<&'o usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn sub_assign(&mut self, other: &'o usize)

Performs the -= operation. Read more
Source§

impl SubAssign<i128> for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn sub_assign(&mut self, other: i128)

Performs the -= operation. Read more
Source§

impl SubAssign<i16> for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn sub_assign(&mut self, other: i16)

Performs the -= operation. Read more
Source§

impl SubAssign<i32> for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn sub_assign(&mut self, other: i32)

Performs the -= operation. Read more
Source§

impl SubAssign<i64> for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn sub_assign(&mut self, other: i64)

Performs the -= operation. Read more
Source§

impl SubAssign<i8> for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: i8)

Performs the -= operation. Read more
Source§

impl SubAssign<isize> for Int<isize>

Available on crate feature _int_isize only.
Source§

fn sub_assign(&mut self, other: isize)

Performs the -= operation. Read more
Source§

impl SubAssign<u128> for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn sub_assign(&mut self, other: u128)

Performs the -= operation. Read more
Source§

impl SubAssign<u16> for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn sub_assign(&mut self, other: u16)

Performs the -= operation. Read more
Source§

impl SubAssign<u32> for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn sub_assign(&mut self, other: u32)

Performs the -= operation. Read more
Source§

impl SubAssign<u64> for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn sub_assign(&mut self, other: u64)

Performs the -= operation. Read more
Source§

impl SubAssign<u8> for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: u8)

Performs the -= operation. Read more
Source§

impl SubAssign<usize> for Int<usize>

Available on crate feature _int_usize only.
Source§

fn sub_assign(&mut self, other: usize)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<i128>

Available on crate feature _int_i128 only.
Source§

fn sub_assign(&mut self, other: Int<i128>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<i16>

Available on crate feature _int_i16 only.
Source§

fn sub_assign(&mut self, other: Int<i16>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<i32>

Available on crate feature _int_i32 only.
Source§

fn sub_assign(&mut self, other: Int<i32>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<i64>

Available on crate feature _int_i64 only.
Source§

fn sub_assign(&mut self, other: Int<i64>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<i8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: Int<i8>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<isize>

Available on crate feature _int_isize only.
Source§

fn sub_assign(&mut self, other: Int<isize>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<u128>

Available on crate feature _int_u128 only.
Source§

fn sub_assign(&mut self, other: Int<u128>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<u16>

Available on crate feature _int_u16 only.
Source§

fn sub_assign(&mut self, other: Int<u16>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<u32>

Available on crate feature _int_u32 only.
Source§

fn sub_assign(&mut self, other: Int<u32>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<u64>

Available on crate feature _int_u64 only.
Source§

fn sub_assign(&mut self, other: Int<u64>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<u8>

Available on crate feature _int_i8 only.
Source§

fn sub_assign(&mut self, other: Int<u8>)

Performs the -= operation. Read more
Source§

impl SubAssign for Int<usize>

Available on crate feature _int_usize only.
Source§

fn sub_assign(&mut self, other: Int<usize>)

Performs the -= operation. Read more
Source§

impl<T: UpperExp> UpperExp for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: UpperHex> UpperHex for Int<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Copy for Int<T>

Source§

impl<T: Eq> Eq for Int<T>

Auto Trait Implementations§

§

impl<T> Freeze for Int<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Int<T>
where T: RefUnwindSafe,

§

impl<T> Send for Int<T>
where T: Send,

§

impl<T> Sync for Int<T>
where T: Sync,

§

impl<T> Unpin for Int<T>
where T: Unpin,

§

impl<T> UnwindSafe for Int<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T, R> Chain<R> for T
where T: ?Sized,

Source§

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Source§

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Source§

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ExtAny for T
where T: Any + ?Sized,

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

impl<T> ExtMem for T
where T: ?Sized,

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T> Hook for T

Source§

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Ungil for T
where T: Send,