pub struct BInt<const N: usize> { /* private fields */ }
Expand description
Big signed integer type, of fixed size which must be known at compile time.
Digits of the underlying
BUint
are stored in little endian (least significant digit first). This integer type aims to exactly replicate the behaviours of Rust’s built-in signed integer types: i8
, i16
, i32
, i64
, i128
and isize
. The const generic parameter N
is the number of digits that are stored in the underlying
BUint
.
BInt
implements all the arithmetic traits from the core::ops
module. The behaviour of the implementation of these traits is the same as for Rust’s primitive integers - i.e. in debug mode it panics on overflow, and in release mode it performs two’s complement wrapping (see https://doc.rust-lang.org/book/ch03-02-data-types.html#integer-overflow). However, an attempt to divide by zero or calculate a remainder with a divisor of zero will always panic, unless the checked_
methods are used, which never panic.
Implementations§
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Checked arithmetic methods which act on self
: self.checked_...
. Each method cannot panic and returns an Option<Self>
. None
is returned when overflow would have occurred or there was an attempt to divide by zero or calculate a remainder with a divisor of zero.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
sourcepub const fn checked_add_unsigned(self, rhs: BUint<N>) -> Option<Self>
pub const fn checked_add_unsigned(self, rhs: BUint<N>) -> Option<Self>
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
sourcepub const fn checked_sub_unsigned(self, rhs: BUint<N>) -> Option<Self>
pub const fn checked_sub_unsigned(self, rhs: BUint<N>) -> Option<Self>
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_mul.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_div.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_div_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_rem.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_rem_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_neg.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_shl.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_shr.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_abs(self) -> Option<Self>
pub const fn checked_abs(self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_pow(self, pow: u32) -> Option<Self>
pub const fn checked_pow(self, pow: u32) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_pow.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>
pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_next_multiple_of.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_ilog.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_ilog2.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.checked_ilog10.
NB: this method is only const
when the nightly
feature is enabled.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Associated constants for this type.
sourcepub const MIN: Self = _
pub const MIN: Self = _
The minimum value that this type can represent.
Examples
use bnum::types::I512;
assert_eq!(!I512::MIN, I512::MAX);
sourcepub const MAX: Self = _
pub const MAX: Self = _
The maximum value that this type can represent.
Examples
use bnum::types::I512;
assert_eq!(I512::MAX.wrapping_add(I512::ONE), I512::MIN);
sourcepub const BITS: u32 = BUint<N>::BITS
pub const BITS: u32 = BUint<N>::BITS
The total number of bits that this type contains.
Examples
use bnum::types::I512;
assert_eq!(I512::BITS, 512);
sourcepub const BYTES: u32 = BUint<N>::BYTES
pub const BYTES: u32 = BUint<N>::BYTES
The total number of bytes that this type contains.
Examples
use bnum::types::I512;
assert_eq!(I512::BYTES, 512 / 8);
sourcepub const ZERO: Self = _
pub const ZERO: Self = _
The value of 0
represented by this type.
Examples
use bnum::types::I512;
assert_eq!(I512::ZERO, I512::from(0u8));
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Methods which convert a BInt
to and from data stored in different endianness.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.from_be.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.from_le.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.to_be.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.to_le.
sourcepub const fn from_be_slice(slice: &[u8]) -> Option<Self>
pub const fn from_be_slice(slice: &[u8]) -> Option<Self>
Create an integer value from a slice of bytes in big endian. The value is wrapped in an Option
as the integer represented by the slice of bytes may represent an integer too large to be represented by the type.
If the length of the slice is shorter than Self::BYTES
, the slice is padded with zeros or ones at the start so that it’s length equals Self::BYTES
. It is padded with ones if the bytes represent a negative integer, otherwise it is padded with zeros.
If the length of the slice is longer than Self::BYTES
, None
will be returned, unless the bytes represent a non-negative integer and leading zeros from the slice can be removed until the length of the slice equals Self::BYTES
, or if the bytes represent a negative integer and leading ones from the slice can be removed until the length of the slice equals Self::BYTES
.
For examples, see the
from_be_slice
method documentation for
BUint
.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn from_le_slice(slice: &[u8]) -> Option<Self>
pub const fn from_le_slice(slice: &[u8]) -> Option<Self>
Creates an integer value from a slice of bytes in little endian. The value is wrapped in an Option
as the bytes may represent an integer too large to be represented by the type.
If the length of the slice is shorter than Self::BYTES
, the slice is padded with zeros or ones at the end so that it’s length equals Self::BYTES
. It is padded with ones if the bytes represent a negative integer, otherwise it is padded with zeros.
If the length of the slice is longer than Self::BYTES
, None
will be returned, unless the bytes represent a non-negative integer and trailing zeros from the slice can be removed until the length of the slice equals Self::BYTES
, or if the bytes represent a negative integer and trailing ones from the slice can be removed until the length of the slice equals Self::BYTES
.
For examples, see the
from_le_slice
method documentation for
BUint
.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn to_be_bytes(self) -> [u8; { _ }]
pub const fn to_be_bytes(self) -> [u8; { _ }]
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.to_be_bytes.
This is supported on the crate feature nightly
only.
sourcepub const fn to_le_bytes(self) -> [u8; { _ }]
pub const fn to_le_bytes(self) -> [u8; { _ }]
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.to_le_bytes.
This is supported on the crate feature nightly
only.
sourcepub const fn to_ne_bytes(self) -> [u8; { _ }]
pub const fn to_ne_bytes(self) -> [u8; { _ }]
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.to_ne_bytes.
This is supported on the crate feature nightly
only.
sourcepub const fn from_be_bytes(bytes: [u8; { _ }]) -> Self
pub const fn from_be_bytes(bytes: [u8; { _ }]) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.from_be_bytes.
This is supported on the crate feature nightly
only.
sourcepub const fn from_le_bytes(bytes: [u8; { _ }]) -> Self
pub const fn from_le_bytes(bytes: [u8; { _ }]) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.from_le_bytes.
This is supported on the crate feature nightly
only.
sourcepub const fn from_ne_bytes(bytes: [u8; { _ }]) -> Self
pub const fn from_ne_bytes(bytes: [u8; { _ }]) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.from_ne_bytes.
This is supported on the crate feature nightly
only.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Overflowing arithmetic methods which act on self
: self.overflowing_...
. Each method returns a tuple of type (Self, bool)
where the first item of the tuple is the result of the calculation truncated to the number of bits of self
, and the second item is a boolean which indicates whether overflow occurred (i.e. if the number of bits of the result of the calculation exceeded the number of bits of self
).
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
sourcepub const fn overflowing_add_unsigned(self, rhs: BUint<N>) -> (Self, bool)
pub const fn overflowing_add_unsigned(self, rhs: BUint<N>) -> (Self, bool)
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
sourcepub const fn overflowing_sub_unsigned(self, rhs: BUint<N>) -> (Self, bool)
pub const fn overflowing_sub_unsigned(self, rhs: BUint<N>) -> (Self, bool)
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_mul.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_div.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_div_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_rem.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_rem_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_neg.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_shl.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_shr.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn overflowing_pow(self, pow: u32) -> (Self, bool)
pub const fn overflowing_pow(self, pow: u32) -> (Self, bool)
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.overflowing_pow.
NB: this method is only const
when the nightly
feature is enabled.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Methods which convert a BInt
between different types in a given radix (base).
sourcepub fn parse_bytes(buf: &[u8], radix: u32) -> Option<Self>
pub fn parse_bytes(buf: &[u8], radix: u32) -> Option<Self>
Converts a byte slice in a given base to an integer. The input slice must contain ascii/utf8 characters in [0-9a-zA-Z].
This function is equivalent to the from_str_radix
function for a string slice equivalent to the byte slice and the same radix.
Returns None
if the conversion of the byte slice to string slice fails or if a digit is larger than or equal to the given radix, otherwise the integer is wrapped in Some
.
sourcepub fn from_radix_be(buf: &[u8], radix: u32) -> Option<Self>
pub fn from_radix_be(buf: &[u8], radix: u32) -> Option<Self>
Converts a slice of big-endian digits in the given radix to an integer. The digits are first converted to an unsigned integer, then this is transmuted to a signed integer. Each u8
of the slice is interpreted as one digit of base radix
of the number, so this function will return None
if any digit is greater than or equal to radix
, otherwise the integer is wrapped in Some
.
For examples, see the
from_radix_be
method documentation for BUint
.
sourcepub fn from_radix_le(buf: &[u8], radix: u32) -> Option<Self>
pub fn from_radix_le(buf: &[u8], radix: u32) -> Option<Self>
Converts a slice of big-endian digits in the given radix to an integer. The digits are first converted to an unsigned integer, then this is transmuted to a signed integer. Each u8
of the slice is interpreted as one digit of base radix
of the number, so this function will return None
if any digit is greater than or equal to radix
, otherwise the integer is wrapped in Some
.
For examples, see the
from_radix_le
method documentation for BUint
.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix
:
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36 inclusive.
For examples, see the
from_str_radix
method documentation for BUint
.
sourcepub fn to_str_radix(&self, radix: u32) -> String
pub fn to_str_radix(&self, radix: u32) -> String
Returns the integer as a string in the given radix.
Panics
This function panics if radix
is not in the range from 2 to 36 inclusive.
For examples, see the
to_str_radix
method documentation for BUint
.
sourcepub fn to_radix_be(&self, radix: u32) -> Vec<u8>
pub fn to_radix_be(&self, radix: u32) -> Vec<u8>
Returns the integer’s underlying representation as an unsigned integer in the given base in big-endian digit order.
Panics
This function panics if radix
is not in the range from 2 to 256 inclusive.
For examples, see the
to_radix_be
method documentation for BUint
sourcepub fn to_radix_le(&self, radix: u32) -> Vec<u8>
pub fn to_radix_le(&self, radix: u32) -> Vec<u8>
Returns the integer’s underlying representation as an unsigned integer in the given base in little-endian digit order.
Panics
This function panics if radix
is not in the range from 2 to 256 inclusive.
For examples, see the
to_radix_le
method documentation for BUint
.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Saturating arithmetic methods which act on self
: self.saturating_...
. For each method, if overflow or underflow occurs, the largest or smallest value that can be represented by Self
is returned instead.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_add_unsigned(self, rhs: BUint<N>) -> Self
pub const fn saturating_add_unsigned(self, rhs: BUint<N>) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_sub_unsigned(self, rhs: BUint<N>) -> Self
pub const fn saturating_sub_unsigned(self, rhs: BUint<N>) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.saturating_mul.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.saturating_div.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn saturating_neg(self) -> Self
pub const fn saturating_neg(self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.saturating_neg.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn saturating_abs(self) -> Self
pub const fn saturating_abs(self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.saturating_abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.saturating_pow.
NB: this method is only const
when the nightly
feature is enabled.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Unchecked arithmetic methods which act on self
: self.unchecked_...
. Each method results in undefined behavior if overflow/underflow occurs, i.e. when the checked equivalent would return None
.
sourcepub unsafe fn unchecked_add(self, rhs: Self) -> Self
pub unsafe fn unchecked_add(self, rhs: Self) -> Self
sourcepub unsafe fn unchecked_sub(self, rhs: Self) -> Self
pub unsafe fn unchecked_sub(self, rhs: Self) -> Self
sourcepub unsafe fn unchecked_mul(self, rhs: Self) -> Self
pub unsafe fn unchecked_mul(self, rhs: Self) -> Self
sourcepub unsafe fn unchecked_shl(self, rhs: Self) -> Self
pub unsafe fn unchecked_shl(self, rhs: Self) -> Self
sourcepub unsafe fn unchecked_shr(self, rhs: Self) -> Self
pub unsafe fn unchecked_shr(self, rhs: Self) -> Self
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
Wrapping arithmetic methods which act on self
: self.wrapping_...
. Each method returns of the calculation truncated to the number of bits of self
, i.e. they each return the first item in the tuple returned by their overflowing equivalent.
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
sourcepub const fn wrapping_add_unsigned(self, rhs: BUint<N>) -> Self
pub const fn wrapping_add_unsigned(self, rhs: BUint<N>) -> Self
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
sourcepub const fn wrapping_sub_unsigned(self, rhs: BUint<N>) -> Self
pub const fn wrapping_sub_unsigned(self, rhs: BUint<N>) -> Self
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_div.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_div_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_rem.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_rem_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_neg.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_shl.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_shr.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.wrapping_abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn wrapping_pow(self, pow: u32) -> Self
pub const fn wrapping_pow(self, pow: u32) -> Self
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.count_ones.
Examples
use bnum::types::I256;
let n = I256::from(0b010111101010000u16);
assert_eq!(n.count_ones(), 7);
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.count_zeros.
Examples
use bnum::types::I256;
assert_eq!((!I256::ZERO).count_zeros(), 0);
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.leading_zeros.
Examples
use bnum::types::I256;
let n = I256::ZERO;
assert_eq!(n.leading_zeros(), 256);
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.trailing_zeros.
Examples
use bnum::types::I256;
let n = (!I256::ZERO) << 6u32;
assert_eq!(n.trailing_zeros(), 6);
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.leading_ones.
Examples
use bnum::types::I256;
let n = !I256::ZERO;
assert_eq!(n.leading_ones(), 256);
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of self
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.trailing_ones.
Examples
use bnum::types::I256;
let n = I256::from(0b1000101011011u16);
assert_eq!(n.trailing_ones(), 2);
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.rotate_left.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
self.rotate_right(n)
is equivalent to self.rotate_left(Self::BITS - n)
.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.rotate_right.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.swap_bytes.
Examples
use bnum::types::I256;
let n = I256::from(0x12345678901234567890123456789012i128);
assert_eq!(n.swap_bytes().swap_bytes(), n);
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.reverse_bits.
Examples
use bnum::types::I256;
let n = I256::from(0x12345678901234567890123456789012i128);
assert_eq!(n.reverse_bits().reverse_bits(), n);
sourcepub const fn unsigned_abs(self) -> BUint<N>
pub const fn unsigned_abs(self) -> BUint<N>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.unsigned_abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.pow.
Examples
use bnum::types::I256;
let n = I256::from(3u8);
assert_eq!(n.pow(5), (243u8).into());
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.div_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.rem_euclid.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.abs.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
sourcepub const fn is_power_of_two(self) -> bool
pub const fn is_power_of_two(self) -> bool
Returns true
if and only if self == 2^k
for some integer k
.
Examples
use bnum::types::I256;
let n = I256::from(1i16 << 12);
assert!(n.is_power_of_two());
let m = I256::from(90i8);
assert!(!m.is_power_of_two());
assert!(!((-n).is_power_of_two()));
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.ilog.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.ilog2.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.ilog10.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn abs_diff(self, other: Self) -> BUint<N>
pub const fn abs_diff(self, other: Self) -> BUint<N>
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.abs_diff.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn next_multiple_of(self, rhs: Self) -> Self
pub const fn next_multiple_of(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.next_multiple_of.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn div_floor(self, rhs: Self) -> Self
pub const fn div_floor(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.div_floor.
NB: this method is only const
when the nightly
feature is enabled.
sourcepub const fn div_ceil(self, rhs: Self) -> Self
pub const fn div_ceil(self, rhs: Self) -> Self
See also: https://doc.rust-lang.org/std/primitive.i64.html#method.div_ceil.
NB: this method is only const
when the nightly
feature is enabled.
source§impl<const N: usize> BInt<N>
impl<const N: usize> BInt<N>
sourcepub const fn bits(&self) -> u32
pub const fn bits(&self) -> u32
Returns the smallest number of bits necessary to represent self
.
This is equal to the size of the type in bits minus the leading zeros of self
.
Examples
use bnum::types::I256;
assert_eq!(I256::from(0b1111001010100u16).bits(), 13);
assert_eq!(I256::ZERO.bits(), 0);
sourcepub const fn bit(&self, b: u32) -> bool
pub const fn bit(&self, b: u32) -> bool
Returns a boolean representing the bit in the given position (true
if the bit is set). The least significant bit is at index 0
, the most significant bit is at index Self::BITS - 1
Examples
use bnum::types::I256;
let n = I256::from(0b001010100101010101u32);
assert!(n.bit(0));
assert!(!n.bit(1));
assert!(!n.bit(I256::BITS - 1));
sourcepub const fn is_zero(&self) -> bool
pub const fn is_zero(&self) -> bool
Returns whether self
is zero.
Examples
use bnum::types::I256;
assert!(I256::ZERO.is_zero());
assert!(!I256::ONE.is_zero());
sourcepub const fn is_one(&self) -> bool
pub const fn is_one(&self) -> bool
Returns whether self
is one.
Examples
use bnum::types::I256;
assert!(I256::ONE.is_one());
assert!(!I256::MAX.is_one());
Trait Implementations§
source§impl<const N: usize> AddAssign<&BInt<N>> for BInt<N>
impl<const N: usize> AddAssign<&BInt<N>> for BInt<N>
source§const fn add_assign(&mut self, rhs: &BInt<N>)
const fn add_assign(&mut self, rhs: &BInt<N>)
+=
operation. Read moresource§impl<const N: usize> AddAssign<BInt<N>> for BInt<N>
impl<const N: usize> AddAssign<BInt<N>> for BInt<N>
source§const fn add_assign(&mut self, rhs: BInt<N>)
const fn add_assign(&mut self, rhs: BInt<N>)
+=
operation. Read moresource§impl<const N: usize> BitAndAssign<&BInt<N>> for BInt<N>
impl<const N: usize> BitAndAssign<&BInt<N>> for BInt<N>
source§const fn bitand_assign(&mut self, rhs: &BInt<N>)
const fn bitand_assign(&mut self, rhs: &BInt<N>)
&=
operation. Read moresource§impl<const N: usize> BitAndAssign<BInt<N>> for BInt<N>
impl<const N: usize> BitAndAssign<BInt<N>> for BInt<N>
source§const fn bitand_assign(&mut self, rhs: BInt<N>)
const fn bitand_assign(&mut self, rhs: BInt<N>)
&=
operation. Read moresource§impl<const N: usize> BitOrAssign<&BInt<N>> for BInt<N>
impl<const N: usize> BitOrAssign<&BInt<N>> for BInt<N>
source§const fn bitor_assign(&mut self, rhs: &BInt<N>)
const fn bitor_assign(&mut self, rhs: &BInt<N>)
|=
operation. Read moresource§impl<const N: usize> BitOrAssign<BInt<N>> for BInt<N>
impl<const N: usize> BitOrAssign<BInt<N>> for BInt<N>
source§const fn bitor_assign(&mut self, rhs: BInt<N>)
const fn bitor_assign(&mut self, rhs: BInt<N>)
|=
operation. Read moresource§impl<const N: usize> BitXorAssign<&BInt<N>> for BInt<N>
impl<const N: usize> BitXorAssign<&BInt<N>> for BInt<N>
source§const fn bitxor_assign(&mut self, rhs: &BInt<N>)
const fn bitxor_assign(&mut self, rhs: &BInt<N>)
^=
operation. Read moresource§impl<const N: usize> BitXorAssign<BInt<N>> for BInt<N>
impl<const N: usize> BitXorAssign<BInt<N>> for BInt<N>
source§const fn bitxor_assign(&mut self, rhs: BInt<N>)
const fn bitxor_assign(&mut self, rhs: BInt<N>)
^=
operation. Read moresource§impl<const N: usize> CheckedAdd for BInt<N>
impl<const N: usize> CheckedAdd for BInt<N>
source§fn checked_add(&self, rhs: &Self) -> Option<Self>
fn checked_add(&self, rhs: &Self) -> Option<Self>
None
is
returned.source§impl<const N: usize> CheckedDiv for BInt<N>
impl<const N: usize> CheckedDiv for BInt<N>
source§fn checked_div(&self, rhs: &Self) -> Option<Self>
fn checked_div(&self, rhs: &Self) -> Option<Self>
None
is returned.source§impl<const N: usize> CheckedMul for BInt<N>
impl<const N: usize> CheckedMul for BInt<N>
source§fn checked_mul(&self, rhs: &Self) -> Option<Self>
fn checked_mul(&self, rhs: &Self) -> Option<Self>
None
is returned.source§impl<const N: usize> CheckedNeg for BInt<N>
impl<const N: usize> CheckedNeg for BInt<N>
source§fn checked_neg(&self) -> Option<Self>
fn checked_neg(&self) -> Option<Self>
None
for results that can’t be represented, like signed MIN
values that can’t be positive, or non-zero unsigned values that can’t be negative. Read moresource§impl<const N: usize> CheckedRem for BInt<N>
impl<const N: usize> CheckedRem for BInt<N>
source§impl<const N: usize> CheckedShl for BInt<N>
impl<const N: usize> CheckedShl for BInt<N>
source§impl<const N: usize> CheckedShr for BInt<N>
impl<const N: usize> CheckedShr for BInt<N>
source§impl<const N: usize> CheckedSub for BInt<N>
impl<const N: usize> CheckedSub for BInt<N>
source§fn checked_sub(&self, rhs: &Self) -> Option<Self>
fn checked_sub(&self, rhs: &Self) -> Option<Self>
None
is returned.source§impl<'de, const N: usize> Deserialize<'de> for BInt<N>
impl<'de, const N: usize> Deserialize<'de> for BInt<N>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<const N: usize> Distribution<BInt<N>> for Standard
impl<const N: usize> Distribution<BInt<N>> for Standard
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> BInt<N>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> BInt<N>
T
, using rng
as the source of randomness.source§impl<const N: usize> DivAssign<&BInt<N>> for BInt<N>
impl<const N: usize> DivAssign<&BInt<N>> for BInt<N>
source§const fn div_assign(&mut self, rhs: &BInt<N>)
const fn div_assign(&mut self, rhs: &BInt<N>)
/=
operation. Read moresource§impl<const N: usize> DivAssign<BInt<N>> for BInt<N>
impl<const N: usize> DivAssign<BInt<N>> for BInt<N>
source§const fn div_assign(&mut self, rhs: BInt<N>)
const fn div_assign(&mut self, rhs: BInt<N>)
/=
operation. Read moresource§impl<const N: usize> FromPrimitive for BInt<N>
impl<const N: usize> FromPrimitive for BInt<N>
source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§impl<const N: usize> Integer for BInt<N>
impl<const N: usize> Integer for BInt<N>
source§fn is_multiple_of(&self, other: &Self) -> bool
fn is_multiple_of(&self, other: &Self) -> bool
source§fn div_rem(&self, other: &Self) -> (Self, Self)
fn div_rem(&self, other: &Self) -> (Self, Self)
(quotient, remainder)
. Read moresource§fn gcd_lcm(&self, other: &Self) -> (Self, Self)
fn gcd_lcm(&self, other: &Self) -> (Self, Self)
source§fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
source§fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)where
Self: Clone + Signed,
fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self)where
Self: Clone + Signed,
source§fn div_mod_floor(&self, other: &Self) -> (Self, Self)
fn div_mod_floor(&self, other: &Self) -> (Self, Self)
(quotient, remainder)
. Read moresource§impl<const N: usize> MulAddAssign<BInt<N>, BInt<N>> for BInt<N>
impl<const N: usize> MulAddAssign<BInt<N>, BInt<N>> for BInt<N>
source§fn mul_add_assign(&mut self, a: Self, b: Self)
fn mul_add_assign(&mut self, a: Self, b: Self)
source§impl<const N: usize> MulAssign<&BInt<N>> for BInt<N>
impl<const N: usize> MulAssign<&BInt<N>> for BInt<N>
source§const fn mul_assign(&mut self, rhs: &BInt<N>)
const fn mul_assign(&mut self, rhs: &BInt<N>)
*=
operation. Read moresource§impl<const N: usize> MulAssign<BInt<N>> for BInt<N>
impl<const N: usize> MulAssign<BInt<N>> for BInt<N>
source§const fn mul_assign(&mut self, rhs: BInt<N>)
const fn mul_assign(&mut self, rhs: BInt<N>)
*=
operation. Read moresource§impl<const N: usize> Num for BInt<N>
impl<const N: usize> Num for BInt<N>
type FromStrRadixErr = ParseIntError
source§fn from_str_radix(
string: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(
string: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl<const N: usize> Ord for BInt<N>
impl<const N: usize> Ord for BInt<N>
source§impl<const N: usize> PartialEq<BInt<N>> for BInt<N>
impl<const N: usize> PartialEq<BInt<N>> for BInt<N>
source§impl<const N: usize> PartialOrd<BInt<N>> for BInt<N>
impl<const N: usize> PartialOrd<BInt<N>> for BInt<N>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PrimInt for BInt<N>
impl<const N: usize> PrimInt for BInt<N>
source§fn count_ones(self) -> u32
fn count_ones(self) -> u32
self
. Read moresource§fn count_zeros(self) -> u32
fn count_zeros(self) -> u32
self
. Read moresource§fn leading_zeros(self) -> u32
fn leading_zeros(self) -> u32
self
. Read moresource§fn trailing_zeros(self) -> u32
fn trailing_zeros(self) -> u32
self
. Read moresource§fn rotate_left(self, n: u32) -> Self
fn rotate_left(self, n: u32) -> Self
n
, wrapping
the truncated bits to the end of the resulting integer. Read moresource§fn rotate_right(self, n: u32) -> Self
fn rotate_right(self, n: u32) -> Self
n
, wrapping
the truncated bits to the beginning of the resulting integer. Read moresource§fn swap_bytes(self) -> Self
fn swap_bytes(self) -> Self
source§fn from_be(x: Self) -> Self
fn from_be(x: Self) -> Self
source§fn from_le(x: Self) -> Self
fn from_le(x: Self) -> Self
source§fn pow(self, exp: u32) -> Self
fn pow(self, exp: u32) -> Self
exp
, using exponentiation by squaring. Read moresource§fn signed_shl(self, n: u32) -> Self
fn signed_shl(self, n: u32) -> Self
n
, filling
zeros in the least significant bits. Read moresource§fn signed_shr(self, n: u32) -> Self
fn signed_shr(self, n: u32) -> Self
n
, copying
the “sign bit” in the most significant bits even for unsigned types. Read moresource§fn unsigned_shl(self, n: u32) -> Self
fn unsigned_shl(self, n: u32) -> Self
n
, filling
zeros in the least significant bits. Read moresource§fn unsigned_shr(self, n: u32) -> Self
fn unsigned_shr(self, n: u32) -> Self
n
, filling
zeros in the most significant bits. Read moresource§fn leading_ones(self) -> u32
fn leading_ones(self) -> u32
self
. Read moresource§fn trailing_ones(self) -> u32
fn trailing_ones(self) -> u32
self
. Read moresource§fn reverse_bits(self) -> Self
fn reverse_bits(self) -> Self
source§impl<const N: usize> RemAssign<&BInt<N>> for BInt<N>
impl<const N: usize> RemAssign<&BInt<N>> for BInt<N>
source§const fn rem_assign(&mut self, rhs: &BInt<N>)
const fn rem_assign(&mut self, rhs: &BInt<N>)
%=
operation. Read moresource§impl<const N: usize> RemAssign<BInt<N>> for BInt<N>
impl<const N: usize> RemAssign<BInt<N>> for BInt<N>
source§const fn rem_assign(&mut self, rhs: BInt<N>)
const fn rem_assign(&mut self, rhs: BInt<N>)
%=
operation. Read moresource§impl<const N: usize> Roots for BInt<N>
impl<const N: usize> Roots for BInt<N>
source§impl<const N: usize> SampleUniform for BInt<N>
impl<const N: usize> SampleUniform for BInt<N>
§type Sampler = UniformInt<BInt<N>>
type Sampler = UniformInt<BInt<N>>
UniformSampler
implementation supporting type X
.source§impl<const N: usize> Saturating for BInt<N>
impl<const N: usize> Saturating for BInt<N>
source§fn saturating_add(self, rhs: Self) -> Self
fn saturating_add(self, rhs: Self) -> Self
source§fn saturating_sub(self, rhs: Self) -> Self
fn saturating_sub(self, rhs: Self) -> Self
source§impl<const N: usize> SaturatingAdd for BInt<N>
impl<const N: usize> SaturatingAdd for BInt<N>
source§fn saturating_add(&self, rhs: &Self) -> Self
fn saturating_add(&self, rhs: &Self) -> Self
self + other
, saturating at the relevant high or low boundary of
the type.source§impl<const N: usize> SaturatingMul for BInt<N>
impl<const N: usize> SaturatingMul for BInt<N>
source§fn saturating_mul(&self, rhs: &Self) -> Self
fn saturating_mul(&self, rhs: &Self) -> Self
self * other
, saturating at the relevant high or low boundary of
the type.source§impl<const N: usize> SaturatingSub for BInt<N>
impl<const N: usize> SaturatingSub for BInt<N>
source§fn saturating_sub(&self, rhs: &Self) -> Self
fn saturating_sub(&self, rhs: &Self) -> Self
self - other
, saturating at the relevant high or low boundary of
the type.source§impl<const N: usize, const M: usize> ShlAssign<&BInt<M>> for BInt<N>
impl<const N: usize, const M: usize> ShlAssign<&BInt<M>> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &BInt<M>)
const fn shl_assign(&mut self, rhs: &BInt<M>)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShlAssign<&BInt<M>> for BUint<N>
impl<const N: usize, const M: usize> ShlAssign<&BInt<M>> for BUint<N>
source§const fn shl_assign(&mut self, rhs: &BInt<M>)
const fn shl_assign(&mut self, rhs: &BInt<M>)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShlAssign<&BUint<M>> for BInt<N>
impl<const N: usize, const M: usize> ShlAssign<&BUint<M>> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &BUint<M>)
const fn shl_assign(&mut self, rhs: &BUint<M>)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&i128> for BInt<N>
impl<const N: usize> ShlAssign<&i128> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &i128)
const fn shl_assign(&mut self, rhs: &i128)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&i16> for BInt<N>
impl<const N: usize> ShlAssign<&i16> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &i16)
const fn shl_assign(&mut self, rhs: &i16)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&i32> for BInt<N>
impl<const N: usize> ShlAssign<&i32> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &i32)
const fn shl_assign(&mut self, rhs: &i32)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&i64> for BInt<N>
impl<const N: usize> ShlAssign<&i64> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &i64)
const fn shl_assign(&mut self, rhs: &i64)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&i8> for BInt<N>
impl<const N: usize> ShlAssign<&i8> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &i8)
const fn shl_assign(&mut self, rhs: &i8)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&isize> for BInt<N>
impl<const N: usize> ShlAssign<&isize> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &isize)
const fn shl_assign(&mut self, rhs: &isize)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&u128> for BInt<N>
impl<const N: usize> ShlAssign<&u128> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &u128)
const fn shl_assign(&mut self, rhs: &u128)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&u16> for BInt<N>
impl<const N: usize> ShlAssign<&u16> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &u16)
const fn shl_assign(&mut self, rhs: &u16)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&u32> for BInt<N>
impl<const N: usize> ShlAssign<&u32> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &u32)
const fn shl_assign(&mut self, rhs: &u32)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&u64> for BInt<N>
impl<const N: usize> ShlAssign<&u64> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &u64)
const fn shl_assign(&mut self, rhs: &u64)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&u8> for BInt<N>
impl<const N: usize> ShlAssign<&u8> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &u8)
const fn shl_assign(&mut self, rhs: &u8)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<&usize> for BInt<N>
impl<const N: usize> ShlAssign<&usize> for BInt<N>
source§const fn shl_assign(&mut self, rhs: &usize)
const fn shl_assign(&mut self, rhs: &usize)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShlAssign<BInt<M>> for BInt<N>
impl<const N: usize, const M: usize> ShlAssign<BInt<M>> for BInt<N>
source§const fn shl_assign(&mut self, rhs: BInt<M>)
const fn shl_assign(&mut self, rhs: BInt<M>)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShlAssign<BInt<M>> for BUint<N>
impl<const N: usize, const M: usize> ShlAssign<BInt<M>> for BUint<N>
source§const fn shl_assign(&mut self, rhs: BInt<M>)
const fn shl_assign(&mut self, rhs: BInt<M>)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShlAssign<BUint<M>> for BInt<N>
impl<const N: usize, const M: usize> ShlAssign<BUint<M>> for BInt<N>
source§const fn shl_assign(&mut self, rhs: BUint<M>)
const fn shl_assign(&mut self, rhs: BUint<M>)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<i128> for BInt<N>
impl<const N: usize> ShlAssign<i128> for BInt<N>
source§const fn shl_assign(&mut self, rhs: i128)
const fn shl_assign(&mut self, rhs: i128)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<i16> for BInt<N>
impl<const N: usize> ShlAssign<i16> for BInt<N>
source§const fn shl_assign(&mut self, rhs: i16)
const fn shl_assign(&mut self, rhs: i16)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<i32> for BInt<N>
impl<const N: usize> ShlAssign<i32> for BInt<N>
source§const fn shl_assign(&mut self, rhs: i32)
const fn shl_assign(&mut self, rhs: i32)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<i64> for BInt<N>
impl<const N: usize> ShlAssign<i64> for BInt<N>
source§const fn shl_assign(&mut self, rhs: i64)
const fn shl_assign(&mut self, rhs: i64)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<i8> for BInt<N>
impl<const N: usize> ShlAssign<i8> for BInt<N>
source§const fn shl_assign(&mut self, rhs: i8)
const fn shl_assign(&mut self, rhs: i8)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<isize> for BInt<N>
impl<const N: usize> ShlAssign<isize> for BInt<N>
source§const fn shl_assign(&mut self, rhs: isize)
const fn shl_assign(&mut self, rhs: isize)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<u128> for BInt<N>
impl<const N: usize> ShlAssign<u128> for BInt<N>
source§const fn shl_assign(&mut self, rhs: u128)
const fn shl_assign(&mut self, rhs: u128)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<u16> for BInt<N>
impl<const N: usize> ShlAssign<u16> for BInt<N>
source§const fn shl_assign(&mut self, rhs: u16)
const fn shl_assign(&mut self, rhs: u16)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<u32> for BInt<N>
impl<const N: usize> ShlAssign<u32> for BInt<N>
source§const fn shl_assign(&mut self, rhs: u32)
const fn shl_assign(&mut self, rhs: u32)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<u64> for BInt<N>
impl<const N: usize> ShlAssign<u64> for BInt<N>
source§const fn shl_assign(&mut self, rhs: u64)
const fn shl_assign(&mut self, rhs: u64)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<u8> for BInt<N>
impl<const N: usize> ShlAssign<u8> for BInt<N>
source§const fn shl_assign(&mut self, rhs: u8)
const fn shl_assign(&mut self, rhs: u8)
<<=
operation. Read moresource§impl<const N: usize> ShlAssign<usize> for BInt<N>
impl<const N: usize> ShlAssign<usize> for BInt<N>
source§const fn shl_assign(&mut self, rhs: usize)
const fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<&BInt<M>> for BInt<N>
impl<const N: usize, const M: usize> ShrAssign<&BInt<M>> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &BInt<M>)
const fn shr_assign(&mut self, rhs: &BInt<M>)
>>=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<&BInt<M>> for BUint<N>
impl<const N: usize, const M: usize> ShrAssign<&BInt<M>> for BUint<N>
source§const fn shr_assign(&mut self, rhs: &BInt<M>)
const fn shr_assign(&mut self, rhs: &BInt<M>)
>>=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<&BUint<M>> for BInt<N>
impl<const N: usize, const M: usize> ShrAssign<&BUint<M>> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &BUint<M>)
const fn shr_assign(&mut self, rhs: &BUint<M>)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&i128> for BInt<N>
impl<const N: usize> ShrAssign<&i128> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &i128)
const fn shr_assign(&mut self, rhs: &i128)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&i16> for BInt<N>
impl<const N: usize> ShrAssign<&i16> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &i16)
const fn shr_assign(&mut self, rhs: &i16)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&i32> for BInt<N>
impl<const N: usize> ShrAssign<&i32> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &i32)
const fn shr_assign(&mut self, rhs: &i32)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&i64> for BInt<N>
impl<const N: usize> ShrAssign<&i64> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &i64)
const fn shr_assign(&mut self, rhs: &i64)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&i8> for BInt<N>
impl<const N: usize> ShrAssign<&i8> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &i8)
const fn shr_assign(&mut self, rhs: &i8)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&isize> for BInt<N>
impl<const N: usize> ShrAssign<&isize> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &isize)
const fn shr_assign(&mut self, rhs: &isize)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&u128> for BInt<N>
impl<const N: usize> ShrAssign<&u128> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &u128)
const fn shr_assign(&mut self, rhs: &u128)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&u16> for BInt<N>
impl<const N: usize> ShrAssign<&u16> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &u16)
const fn shr_assign(&mut self, rhs: &u16)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&u32> for BInt<N>
impl<const N: usize> ShrAssign<&u32> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &u32)
const fn shr_assign(&mut self, rhs: &u32)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&u64> for BInt<N>
impl<const N: usize> ShrAssign<&u64> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &u64)
const fn shr_assign(&mut self, rhs: &u64)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&u8> for BInt<N>
impl<const N: usize> ShrAssign<&u8> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &u8)
const fn shr_assign(&mut self, rhs: &u8)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<&usize> for BInt<N>
impl<const N: usize> ShrAssign<&usize> for BInt<N>
source§const fn shr_assign(&mut self, rhs: &usize)
const fn shr_assign(&mut self, rhs: &usize)
>>=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<BInt<M>> for BInt<N>
impl<const N: usize, const M: usize> ShrAssign<BInt<M>> for BInt<N>
source§const fn shr_assign(&mut self, rhs: BInt<M>)
const fn shr_assign(&mut self, rhs: BInt<M>)
>>=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<BInt<M>> for BUint<N>
impl<const N: usize, const M: usize> ShrAssign<BInt<M>> for BUint<N>
source§const fn shr_assign(&mut self, rhs: BInt<M>)
const fn shr_assign(&mut self, rhs: BInt<M>)
>>=
operation. Read moresource§impl<const N: usize, const M: usize> ShrAssign<BUint<M>> for BInt<N>
impl<const N: usize, const M: usize> ShrAssign<BUint<M>> for BInt<N>
source§const fn shr_assign(&mut self, rhs: BUint<M>)
const fn shr_assign(&mut self, rhs: BUint<M>)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<i128> for BInt<N>
impl<const N: usize> ShrAssign<i128> for BInt<N>
source§const fn shr_assign(&mut self, rhs: i128)
const fn shr_assign(&mut self, rhs: i128)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<i16> for BInt<N>
impl<const N: usize> ShrAssign<i16> for BInt<N>
source§const fn shr_assign(&mut self, rhs: i16)
const fn shr_assign(&mut self, rhs: i16)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<i32> for BInt<N>
impl<const N: usize> ShrAssign<i32> for BInt<N>
source§const fn shr_assign(&mut self, rhs: i32)
const fn shr_assign(&mut self, rhs: i32)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<i64> for BInt<N>
impl<const N: usize> ShrAssign<i64> for BInt<N>
source§const fn shr_assign(&mut self, rhs: i64)
const fn shr_assign(&mut self, rhs: i64)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<i8> for BInt<N>
impl<const N: usize> ShrAssign<i8> for BInt<N>
source§const fn shr_assign(&mut self, rhs: i8)
const fn shr_assign(&mut self, rhs: i8)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<isize> for BInt<N>
impl<const N: usize> ShrAssign<isize> for BInt<N>
source§const fn shr_assign(&mut self, rhs: isize)
const fn shr_assign(&mut self, rhs: isize)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<u128> for BInt<N>
impl<const N: usize> ShrAssign<u128> for BInt<N>
source§const fn shr_assign(&mut self, rhs: u128)
const fn shr_assign(&mut self, rhs: u128)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<u16> for BInt<N>
impl<const N: usize> ShrAssign<u16> for BInt<N>
source§const fn shr_assign(&mut self, rhs: u16)
const fn shr_assign(&mut self, rhs: u16)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<u32> for BInt<N>
impl<const N: usize> ShrAssign<u32> for BInt<N>
source§const fn shr_assign(&mut self, rhs: u32)
const fn shr_assign(&mut self, rhs: u32)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<u64> for BInt<N>
impl<const N: usize> ShrAssign<u64> for BInt<N>
source§const fn shr_assign(&mut self, rhs: u64)
const fn shr_assign(&mut self, rhs: u64)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<u8> for BInt<N>
impl<const N: usize> ShrAssign<u8> for BInt<N>
source§const fn shr_assign(&mut self, rhs: u8)
const fn shr_assign(&mut self, rhs: u8)
>>=
operation. Read moresource§impl<const N: usize> ShrAssign<usize> for BInt<N>
impl<const N: usize> ShrAssign<usize> for BInt<N>
source§const fn shr_assign(&mut self, rhs: usize)
const fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moresource§impl<const N: usize> Signed for BInt<N>
impl<const N: usize> Signed for BInt<N>
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
source§impl<const N: usize> SubAssign<&BInt<N>> for BInt<N>
impl<const N: usize> SubAssign<&BInt<N>> for BInt<N>
source§const fn sub_assign(&mut self, rhs: &BInt<N>)
const fn sub_assign(&mut self, rhs: &BInt<N>)
-=
operation. Read moresource§impl<const N: usize> SubAssign<BInt<N>> for BInt<N>
impl<const N: usize> SubAssign<BInt<N>> for BInt<N>
source§const fn sub_assign(&mut self, rhs: BInt<N>)
const fn sub_assign(&mut self, rhs: BInt<N>)
-=
operation. Read moresource§impl<const N: usize> ToPrimitive for BInt<N>
impl<const N: usize> ToPrimitive for BInt<N>
source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read moresource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moresource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.source§impl<const N: usize> WrappingAdd for BInt<N>
impl<const N: usize> WrappingAdd for BInt<N>
source§fn wrapping_add(&self, rhs: &Self) -> Self
fn wrapping_add(&self, rhs: &Self) -> Self
self + other
, wrapping around at the boundary of
the type.source§impl<const N: usize> WrappingMul for BInt<N>
impl<const N: usize> WrappingMul for BInt<N>
source§fn wrapping_mul(&self, rhs: &Self) -> Self
fn wrapping_mul(&self, rhs: &Self) -> Self
self * other
, wrapping around at the boundary
of the type.source§impl<const N: usize> WrappingNeg for BInt<N>
impl<const N: usize> WrappingNeg for BInt<N>
source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self
,
wrapping around at the boundary of the type. Read moresource§impl<const N: usize> WrappingShl for BInt<N>
impl<const N: usize> WrappingShl for BInt<N>
source§fn wrapping_shl(&self, rhs: u32) -> Self
fn wrapping_shl(&self, rhs: u32) -> Self
self << mask(rhs)
,
where mask
removes any high order bits of rhs
that would
cause the shift to exceed the bitwidth of the type. Read moresource§impl<const N: usize> WrappingShr for BInt<N>
impl<const N: usize> WrappingShr for BInt<N>
source§fn wrapping_shr(&self, rhs: u32) -> Self
fn wrapping_shr(&self, rhs: u32) -> Self
self >> mask(rhs)
,
where mask
removes any high order bits of rhs
that would
cause the shift to exceed the bitwidth of the type. Read moresource§impl<const N: usize> WrappingSub for BInt<N>
impl<const N: usize> WrappingSub for BInt<N>
source§fn wrapping_sub(&self, rhs: &Self) -> Self
fn wrapping_sub(&self, rhs: &Self) -> Self
self - other
, wrapping around at the boundary
of the type.impl<const N: usize> Copy for BInt<N>
impl<const N: usize> Eq for BInt<N>
Auto Trait Implementations§
impl<const N: usize> RefUnwindSafe for BInt<N>
impl<const N: usize> Send for BInt<N>
impl<const N: usize> Sync for BInt<N>
impl<const N: usize> Unpin for BInt<N>
impl<const N: usize> UnwindSafe for BInt<N>
Blanket Implementations§
source§impl<I> Average for Iwhere
&'a I: for<'a, 'b> BitAnd<&'b I, Output = I> + for<'a, 'b> BitOr<&'b I, Output = I> + for<'a, 'b> BitXor<&'b I, Output = I>,
I: Integer + Shr<usize, Output = I>,
impl<I> Average for Iwhere
&'a I: for<'a, 'b> BitAnd<&'b I, Output = I> + for<'a, 'b> BitOr<&'b I, Output = I> + for<'a, 'b> BitXor<&'b I, Output = I>,
I: Integer + Shr<usize, Output = I>,
source§fn average_floor(&self, other: &I) -> I
fn average_floor(&self, other: &I) -> I
Returns the floor value of the average of self
and other
.
source§fn average_ceil(&self, other: &I) -> I
fn average_ceil(&self, other: &I) -> I
Returns the ceil value of the average of self
and other
.
source§impl<T> LowerBounded for Twhere
T: Bounded,
impl<T> LowerBounded for Twhere
T: Bounded,
source§impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
source§fn borrow(&self) -> &Borrowed
fn borrow(&self) -> &Borrowed
Borrow::borrow