Struct apint::Int [−][src]
pub struct Int { /* fields omitted */ }
Signed machine integer with arbitrary bitwidths and modulo arithmetics.
Thin convenience wrapper around ApInt
for static signed interpretation of the value.
This very cheaply transformes to and from ApInt
and UInt
instances and together with
UInt
offers a more elegant and higher-level abstraction interface to the lower-level ApInt
.
Methods
impl Int
[src]
impl Int
pub fn into_apint(self) -> ApInt
[src]
pub fn into_apint(self) -> ApInt
Transforms this Int
into an equivalent ApInt
instance.
pub fn into_unsigned(self) -> UInt
[src]
pub fn into_unsigned(self) -> UInt
Transforms this Int
into an equivalent UInt
instance.
impl Int
[src]
impl Int
pub fn from_bit<B>(bit: B) -> Int where
B: Into<Bit>,
[src]
pub fn from_bit<B>(bit: B) -> Int where
B: Into<Bit>,
Creates a new Int
from the given Bit
value with a bit width of 1
.
This function is generic over types that are convertible to Bit
such as bool
.
pub fn from_i8(val: i8) -> Int
[src]
pub fn from_i8(val: i8) -> Int
Creates a new Int
from a given i8
value with a bit-width of 8.
pub fn from_i16(val: i16) -> Int
[src]
pub fn from_i16(val: i16) -> Int
Creates a new Int
from a given i16
value with a bit-width of 16.
pub fn from_i32(val: i32) -> Int
[src]
pub fn from_i32(val: i32) -> Int
Creates a new Int
from a given i32
value with a bit-width of 32.
pub fn from_i64(val: i64) -> Int
[src]
pub fn from_i64(val: i64) -> Int
Creates a new Int
from a given i64
value with a bit-width of 64.
pub fn from_i128(val: i128) -> Int
[src]
pub fn from_i128(val: i128) -> Int
Creates a new Int
from a given i64
value with a bit-width of 64.
pub fn zero(width: BitWidth) -> Int
[src]
pub fn zero(width: BitWidth) -> Int
Creates a new Int
with the given bit width that represents zero.
pub fn one(width: BitWidth) -> Int
[src]
pub fn one(width: BitWidth) -> Int
Creates a new Int
with the given bit width that represents one.
pub fn all_unset(width: BitWidth) -> Int
[src]
pub fn all_unset(width: BitWidth) -> Int
Creates a new Int
with the given bit width that has all bits unset.
Note: This is equal to calling Int::zero
with the given width
.
pub fn all_set(width: BitWidth) -> Int
[src]
pub fn all_set(width: BitWidth) -> Int
Creates a new Int
with the given bit width that has all bits set.
Note
- This is equal to minus one on any twos-complement machine.
pub fn min_value(width: BitWidth) -> Int
[src]
pub fn min_value(width: BitWidth) -> Int
Returns the smallest Int
that can be represented by the given BitWidth
.
pub fn max_value(width: BitWidth) -> Int
[src]
pub fn max_value(width: BitWidth) -> Int
Returns the largest Int
that can be represented by the given BitWidth
.
impl Int
[src]
impl Int
pub fn is_zero(&self) -> bool
[src]
pub fn is_zero(&self) -> bool
Returns true
if this Int
represents the value zero (0
).
Note
- Zero (
0
) is also called the additive neutral element. - This operation is more efficient than comparing two instances
of
Int
for the same reason.
pub fn is_one(&self) -> bool
[src]
pub fn is_one(&self) -> bool
Returns true
if this Int
represents the value one (1
).
Note
- One (
1
) is also called the multiplicative neutral element. - This operation is more efficient than comparing two instances
of
Int
for the same reason.
pub fn is_even(&self) -> bool
[src]
pub fn is_even(&self) -> bool
Returns true
if this Int
represents an even number.
pub fn is_odd(&self) -> bool
[src]
pub fn is_odd(&self) -> bool
Returns true
if this Int
represents an odd number.
pub fn is_positive(&self) -> bool
[src]
pub fn is_positive(&self) -> bool
Returns true
if the value of this Int
is positive.
pub fn is_negative(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
Returns true
if the value of this Int
is negative.
pub fn signum(&self) -> i8
[src]
pub fn signum(&self) -> i8
Returns a number representing sign of this ApInt
.
0
if the number is zero1
if the number is positive-1
if the number is negative
pub fn into_abs(self) -> Int
[src]
pub fn into_abs(self) -> Int
Returns an absolute value representation of this Int
.
Note
- Consumes
self
. - Does nothing for positive
Int
instances.
pub fn abs(&mut self)
[src]
pub fn abs(&mut self)
Converts this Int
into its absolute value representation.
- Does nothing for positive
Int
instances.
impl Int
[src]
impl Int
pub fn checked_lt(&self, rhs: &Int) -> Result<bool>
[src]
pub fn checked_lt(&self, rhs: &Int) -> Result<bool>
Less-than (lt
) comparison between self
and rhs
.
Note
- Returns
Ok(true)
ifself < rhs
. - Interprets both
Int
instances as unsigned values.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_le(&self, rhs: &Int) -> Result<bool>
[src]
pub fn checked_le(&self, rhs: &Int) -> Result<bool>
Less-equals (le
) comparison between self
and rhs
.
Note
- Returns
Ok(true)
ifself <= rhs
. - Interprets both
Int
instances as unsigned values.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_gt(&self, rhs: &Int) -> Result<bool>
[src]
pub fn checked_gt(&self, rhs: &Int) -> Result<bool>
Greater-than (gt
) comparison between self
and rhs
.
Note
- Returns
Ok(true)
ifself > rhs
. - Interprets both
Int
instances as unsigned values.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_ge(&self, rhs: &Int) -> Result<bool>
[src]
pub fn checked_ge(&self, rhs: &Int) -> Result<bool>
impl Int
[src]
impl Int
pub fn resize_to_bool(&self) -> bool
[src]
pub fn resize_to_bool(&self) -> bool
Resizes this Int
to a bool
primitive type.
Bits in this Int
that are not within the bounds
of the bool
are being ignored.
Note
- Basically this returns
true
if the least significant bit of thisInt
is1
andfalse
otherwise.
pub fn resize_to_i8(&self) -> i8
[src]
pub fn resize_to_i8(&self) -> i8
Resizes this Int
to a i8
primitive type.
Note
- All bits but the least significant
8
bits are being ignored by this operation to construct the result.
pub fn resize_to_i16(&self) -> i16
[src]
pub fn resize_to_i16(&self) -> i16
Resizes this Int
to a i16
primitive type.
Note
- All bits but the least significant
16
bits are being ignored by this operation to construct the result.
pub fn resize_to_i32(&self) -> i32
[src]
pub fn resize_to_i32(&self) -> i32
Resizes this Int
to a i32
primitive type.
Note
- All bits but the least significant
32
bits are being ignored by this operation to construct the result.
pub fn resize_to_i64(&self) -> i64
[src]
pub fn resize_to_i64(&self) -> i64
Resizes this Int
to a i64
primitive type.
Note
- All bits but the least significant
64
bits are being ignored by this operation to construct the result.
pub fn resize_to_i128(&self) -> i128
[src]
pub fn resize_to_i128(&self) -> i128
Resizes this Int
to a i128
primitive type.
Note
- All bits but the least significant
128
bits are being ignored by this operation to construct the result.
impl Int
[src]
impl Int
pub fn try_to_bool(&self) -> Result<bool>
[src]
pub fn try_to_bool(&self) -> Result<bool>
Tries to represent the value of this Int
as a bool
.
Note
This returns true
if the value represented by this Int
is 1
, returns false
if the value represented by this
Int
is 0
and returns an error otherwise.
Errors
- If the value represented by this
Int
can not be represented by abool
.
pub fn try_to_i8(&self) -> Result<i8>
[src]
pub fn try_to_i8(&self) -> Result<i8>
Tries to represent the value of this Int
as a i8
.
Note
- This conversion is possible as long as the value represented
by this
Int
does not exceed the maximum value ofi8
.
Errors
- If the value represented by this
Int
can not be represented by au8
.
pub fn try_to_i16(&self) -> Result<i16>
[src]
pub fn try_to_i16(&self) -> Result<i16>
Tries to represent the value of this Int
as a i16
.
Note
- This conversion is possible as long as the value represented
by this
Int
does not exceed the maximum value ofi16
.
Errors
- If the value represented by this
Int
can not be represented by ai16
.
pub fn try_to_i32(&self) -> Result<i32>
[src]
pub fn try_to_i32(&self) -> Result<i32>
Tries to represent the value of this Int
as a i32
.
Note
- This conversion is possible as long as the value represented
by this
Int
does not exceed the maximum value ofi32
.
Errors
- If the value represented by this
Int
can not be represented by ai32
.
pub fn try_to_i64(&self) -> Result<i64>
[src]
pub fn try_to_i64(&self) -> Result<i64>
Tries to represent the value of this Int
as a i64
.
Note
- This conversion is possible as long as the value represented
by this
Int
does not exceed the maximum value ofi64
.
Errors
- If the value represented by this
Int
can not be represented by ai64
.
pub fn try_to_i128(&self) -> Result<i128>
[src]
pub fn try_to_i128(&self) -> Result<i128>
Tries to represent the value of this Int
as a i128
.
Note
- This conversion is possible as long as the value represented
by this
Int
does not exceed the maximum value ofi128
.
Complexity
- 𝒪(n) where n is the number of digits of this
Int
.
Errors
- If the value represented by this
Int
can not be represented by ai128
.
impl Int
[src]
impl Int
pub fn checked_shl_assign<S>(&mut self, shift_amount: S) -> Result<()> where
S: Into<ShiftAmount>,
[src]
pub fn checked_shl_assign<S>(&mut self, shift_amount: S) -> Result<()> where
S: Into<ShiftAmount>,
Shift this Int
left by the given shift_amount
bits.
This operation is inplace and will not allocate memory.
Errors
- If the given
shift_amount
is invalid for the bit width of thisInt
.
pub fn into_checked_shl<S>(self, shift_amount: S) -> Result<Int> where
S: Into<ShiftAmount>,
[src]
pub fn into_checked_shl<S>(self, shift_amount: S) -> Result<Int> where
S: Into<ShiftAmount>,
Shift this Int
left by the given shift_amount
bits and returns the result.
This operation is inplace and will not allocate memory.
Errors
- If the given
shift_amount
is invalid for the bit width of thisInt
.
pub fn checked_shr_assign<S>(&mut self, shift_amount: S) -> Result<()> where
S: Into<ShiftAmount>,
[src]
pub fn checked_shr_assign<S>(&mut self, shift_amount: S) -> Result<()> where
S: Into<ShiftAmount>,
Right-shifts this Int
by the given shift_amount
bits.
This operation is inplace and will not allocate memory.
Errors
- If the given
shift_amount
is invalid for the bit width of thisInt
.
pub fn into_checked_shr<S>(self, shift_amount: S) -> Result<Int> where
S: Into<ShiftAmount>,
[src]
pub fn into_checked_shr<S>(self, shift_amount: S) -> Result<Int> where
S: Into<ShiftAmount>,
Right-shifts this Int
by the given shift_amount
bits
and returns the result.
This operation is inplace and will not allocate memory.
Errors
- If the given
shift_amount
is invalid for the bit width of thisInt
.
impl Int
[src]
impl Int
pub fn random_with_width(width: BitWidth) -> Int
[src]
pub fn random_with_width(width: BitWidth) -> Int
Creates a new Int
with the given BitWidth
and random Digit
s.
pub fn random_with_width_using<R>(width: BitWidth, rng: &mut R) -> Int where
R: Rng,
[src]
pub fn random_with_width_using<R>(width: BitWidth, rng: &mut R) -> Int where
R: Rng,
Creates a new Int
with the given BitWidth
and random Digit
s
using the given random number generator.
Note: This is useful for cryptographic or testing purposes.
pub fn randomize(&mut self)
[src]
pub fn randomize(&mut self)
Randomizes the digits of this Int
inplace.
This won't change its BitWidth
.
pub fn randomize_using<R>(&mut self, rng: &mut R) where
R: Rng,
[src]
pub fn randomize_using<R>(&mut self, rng: &mut R) where
R: Rng,
Randomizes the digits of this Int
inplace using the given
random number generator.
This won't change its BitWidth
.
impl Int
[src]
impl Int
pub fn assign(&mut self, rhs: &Int)
[src]
pub fn assign(&mut self, rhs: &Int)
Assigns rhs
to this Int
.
This mutates digits and may affect the bitwidth of self
which might result in an expensive operations.
After this operation rhs
and self
are equal to each other.
pub fn strict_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn strict_assign(&mut self, rhs: &Int) -> Result<()>
Strictly assigns rhs
to this Int
.
After this operation rhs
and self
are equal to each other.
Note: Strict assigns protect against mutating the bit width
of self
and thus return an error instead of executing a probably
expensive assign
operation.
Errors
- If
rhs
andself
have unmatching bit widths.
impl Int
[src]
impl Int
pub fn into_truncate<W>(self, target_width: W) -> Result<Int> where
W: Into<BitWidth>,
[src]
pub fn into_truncate<W>(self, target_width: W) -> Result<Int> where
W: Into<BitWidth>,
Tries to truncate this Int
inplace to the given target_width
and returns the result.
Note
- This is useful for method chaining.
- For more details look into
truncate
.
Errors
- If the
target_width
is greater than the current width.
pub fn truncate<W>(&mut self, target_width: W) -> Result<()> where
W: Into<BitWidth>,
[src]
pub fn truncate<W>(&mut self, target_width: W) -> Result<()> where
W: Into<BitWidth>,
Tries to truncate this Int
inplace to the given target_width
.
Note
- This is a no-op if
self.width()
andtarget_width
are equal. - This operation is inplace as long as
self.width()
andtarget_width
require the same amount of digits for their representation.
Errors
- If the
target_width
is greater than the current width.
pub fn into_extend<W>(self, target_width: W) -> Result<Int> where
W: Into<BitWidth>,
[src]
pub fn into_extend<W>(self, target_width: W) -> Result<Int> where
W: Into<BitWidth>,
Tries to zero-extend this Int
inplace to the given target_width
and returns the result.
Note
- This is useful for method chaining.
- For more details look into
extend
.
Errors
- If the
target_width
is less than the current width.
pub fn extend<W>(&mut self, target_width: W) -> Result<()> where
W: Into<BitWidth>,
[src]
pub fn extend<W>(&mut self, target_width: W) -> Result<()> where
W: Into<BitWidth>,
Tries to extend this Int
inplace to the given target_width
.
Note
- This is a no-op if
self.width()
andtarget_width
are equal. - This operation is inplace as long as
self.width()
andtarget_width
require the same amount of digits for their representation.
Errors
- If the
target_width
is less than the current width.
pub fn into_resize<W>(self, target_width: W) -> Int where
W: Into<BitWidth>,
[src]
pub fn into_resize<W>(self, target_width: W) -> Int where
W: Into<BitWidth>,
Resizes this Int
to the given target_width
and returns the result.
Note
- This is useful for method chaining.
- For more details look into
resize
.
pub fn resize<W>(&mut self, target_width: W) where
W: Into<BitWidth>,
[src]
pub fn resize<W>(&mut self, target_width: W) where
W: Into<BitWidth>,
impl Int
[src]
impl Int
pub fn into_bitnot(self) -> Self
[src]
pub fn into_bitnot(self) -> Self
Flips all bits of self
and returns the result.
pub fn bitnot(&mut self)
[src]
pub fn bitnot(&mut self)
Flip all bits of this Int
inplace.
pub fn into_checked_bitand(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_bitand(self, rhs: &Int) -> Result<Int>
Tries to bit-and assign this Int
inplace to rhs
and returns the result.
Note: This forwards to
checked_bitand
.
Errors
If self
and rhs
have unmatching bit widths.
pub fn checked_bitand_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_bitand_assign(&mut self, rhs: &Int) -> Result<()>
Bit-and assigns all bits of this Int
with the bits of rhs
.
Note: This operation is inplace of self
and won't allocate memory.
Errors
If self
and rhs
have unmatching bit widths.
pub fn into_checked_bitor(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_bitor(self, rhs: &Int) -> Result<Int>
Tries to bit-and assign this Int
inplace to rhs
and returns the result.
Note: This forwards to
checked_bitor
.
Errors
If self
and rhs
have unmatching bit widths.
pub fn checked_bitor_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_bitor_assign(&mut self, rhs: &Int) -> Result<()>
Bit-or assigns all bits of this Int
with the bits of rhs
.
Note: This operation is inplace of self
and won't allocate memory.
Errors
If self
and rhs
have unmatching bit widths.
pub fn into_checked_bitxor(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_bitxor(self, rhs: &Int) -> Result<Int>
Tries to bit-xor assign this Int
inplace to rhs
and returns the result.
Note: This forwards to
checked_bitxor
.
Errors
If self
and rhs
have unmatching bit widths.
pub fn checked_bitxor_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_bitxor_assign(&mut self, rhs: &Int) -> Result<()>
Bit-xor assigns all bits of this Int
with the bits of rhs
.
Note: This operation is inplace of self
and won't allocate memory.
Errors
If self
and rhs
have unmatching bit widths.
impl Int
[src]
impl Int
pub fn get_bit_at<P>(&self, pos: P) -> Result<Bit> where
P: Into<BitPos>,
[src]
pub fn get_bit_at<P>(&self, pos: P) -> Result<Bit> where
P: Into<BitPos>,
Returns the bit at the given bit position pos
.
This returns
Bit::Set
if the bit atpos
is1
Bit::Unset
otherwise
Errors
- If
pos
is not a valid bit position for the width of thisInt
.
pub fn set_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
[src]
pub fn set_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
Sets the bit at the given bit position pos
to one (1
).
Errors
- If
pos
is not a valid bit position for the width of thisInt
.
pub fn unset_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
[src]
pub fn unset_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
Sets the bit at the given bit position pos
to zero (0
).
Errors
- If
pos
is not a valid bit position for the width of thisInt
.
pub fn flip_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
[src]
pub fn flip_bit_at<P>(&mut self, pos: P) -> Result<()> where
P: Into<BitPos>,
Flips the bit at the given bit position pos
.
Note
- If the bit at the given position was
0
it will be1
after this operation and vice versa.
Errors
- If
pos
is not a valid bit position for the width of thisInt
.
pub fn set_all(&mut self)
[src]
pub fn set_all(&mut self)
Sets all bits of this Int
to one (1
).
pub fn is_all_set(&self) -> bool
[src]
pub fn is_all_set(&self) -> bool
Returns true
if all bits in this Int
are set.
pub fn unset_all(&mut self)
[src]
pub fn unset_all(&mut self)
Sets all bits of this Int
to zero (0
).
pub fn is_all_unset(&self) -> bool
[src]
pub fn is_all_unset(&self) -> bool
Returns true
if all bits in this Int
are unset.
pub fn flip_all(&mut self)
[src]
pub fn flip_all(&mut self)
Flips all bits of this Int
.
pub fn sign_bit(&self) -> Bit
[src]
pub fn sign_bit(&self) -> Bit
Returns the sign bit of this Int
.
Note: This is equal to the most significant bit of this Int
.
pub fn set_sign_bit(&mut self)
[src]
pub fn set_sign_bit(&mut self)
Sets the sign bit of this Int
to one (1
).
pub fn unset_sign_bit(&mut self)
[src]
pub fn unset_sign_bit(&mut self)
Sets the sign bit of this Int
to zero (0
).
pub fn flip_sign_bit(&mut self)
[src]
pub fn flip_sign_bit(&mut self)
Flips the sign bit of this Int
.
Note
- If the sign bit was
0
it will be1
after this operation and vice versa. - Depending on the interpretation of the
Int
this operation changes its signedness.
impl Int
[src]
impl Int
pub fn count_ones(&self) -> usize
[src]
pub fn count_ones(&self) -> usize
Returns the number of ones in the binary representation of this Int
.
pub fn count_zeros(&self) -> usize
[src]
pub fn count_zeros(&self) -> usize
Returns the number of zeros in the binary representation of this Int
.
pub fn leading_zeros(&self) -> usize
[src]
pub fn leading_zeros(&self) -> usize
Returns the number of leading zeros in the binary representation of this Int
.
pub fn trailing_zeros(&self) -> usize
[src]
pub fn trailing_zeros(&self) -> usize
Returns the number of trailing zeros in the binary representation of this Int
.
impl Int
[src]
impl Int
pub fn into_negate(self) -> Int
[src]
pub fn into_negate(self) -> Int
Negates this Int
inplace and returns the result.
Note: This will not allocate memory.
pub fn negate(&mut self)
[src]
pub fn negate(&mut self)
Negates this Int
inplace.
Note: This will not allocate memory.
pub fn into_checked_add(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_add(self, rhs: &Int) -> Result<Int>
Adds rhs
to self
and returns the result.
Note: This will not allocate memory.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_add_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_add_assign(&mut self, rhs: &Int) -> Result<()>
Add-assigns rhs
to self
inplace.
Note: This will not allocate memory.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn into_checked_sub(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_sub(self, rhs: &Int) -> Result<Int>
Subtracts rhs
from self
and returns the result.
Note
In the low-level bit-wise representation there is no difference between signed and unsigned subtraction of fixed bit-width integers. (Cite: LLVM)
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_sub_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_sub_assign(&mut self, rhs: &Int) -> Result<()>
Subtract-assigns rhs
from self
inplace.
Note
In the low-level bit-wise representation there is no difference between signed and unsigned subtraction of fixed bit-width integers. (Cite: LLVM)
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn into_checked_mul(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_mul(self, rhs: &Int) -> Result<Int>
Subtracts rhs
from self
and returns the result.
Note
In the low-level bit-wise representation there is no difference between signed and unsigned multiplication of fixed bit-width integers. (Cite: LLVM)
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_mul_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_mul_assign(&mut self, rhs: &Int) -> Result<()>
Multiply-assigns rhs
to self
inplace.
Note
In the low-level bit-wise representation there is no difference between signed and unsigned multiplication of fixed bit-width integers. (Cite: LLVM)
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn into_checked_div(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_div(self, rhs: &Int) -> Result<Int>
Divides self
by rhs
and returns the result.
Note
- This operation will not allocate memory and computes inplace of
self
. - In the low-level machine abstraction signed division and unsigned division are two different operations.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_div_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_div_assign(&mut self, rhs: &Int) -> Result<()>
Assignes self
to the division of self
by rhs
.
Note
- This operation will not allocate memory and computes inplace of
self
. - In the low-level machine abstraction signed division and unsigned division are two different operations.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn into_checked_rem(self, rhs: &Int) -> Result<Int>
[src]
pub fn into_checked_rem(self, rhs: &Int) -> Result<Int>
Calculates the unsigned remainder of self
by rhs
and returns the result.
Note
- This operation will not allocate memory and computes inplace of
self
. - In the low-level machine abstraction signed division and unsigned division are two different operations.
Errors
- If
self
andrhs
have unmatching bit widths.
pub fn checked_rem_assign(&mut self, rhs: &Int) -> Result<()>
[src]
pub fn checked_rem_assign(&mut self, rhs: &Int) -> Result<()>
Trait Implementations
impl Debug for Int
[src]
impl Debug for Int
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Int
[src]
impl Clone for Int
fn clone(&self) -> Int
[src]
fn clone(&self) -> Int
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Int
[src]
impl PartialEq for Int
fn eq(&self, other: &Int) -> bool
[src]
fn eq(&self, other: &Int) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Int) -> bool
[src]
fn ne(&self, other: &Int) -> bool
This method tests for !=
.
impl Eq for Int
[src]
impl Eq for Int
impl Hash for Int
[src]
impl Hash for Int
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl From<ApInt> for Int
[src]
impl From<ApInt> for Int
impl<B> From<B> for Int where
B: Into<Bit>,
[src]
impl<B> From<B> for Int where
B: Into<Bit>,
impl From<i8> for Int
[src]
impl From<i8> for Int
impl From<i16> for Int
[src]
impl From<i16> for Int
impl From<i32> for Int
[src]
impl From<i32> for Int
impl From<i64> for Int
[src]
impl From<i64> for Int
impl From<i128> for Int
[src]
impl From<i128> for Int
impl From<[i64; 2]> for Int
[src]
impl From<[i64; 2]> for Int
impl From<[i64; 3]> for Int
[src]
impl From<[i64; 3]> for Int
impl From<[i64; 4]> for Int
[src]
impl From<[i64; 4]> for Int
impl From<[i64; 5]> for Int
[src]
impl From<[i64; 5]> for Int
impl From<[i64; 6]> for Int
[src]
impl From<[i64; 6]> for Int
impl From<[i64; 7]> for Int
[src]
impl From<[i64; 7]> for Int
impl From<[i64; 8]> for Int
[src]
impl From<[i64; 8]> for Int
impl From<[i64; 16]> for Int
[src]
impl From<[i64; 16]> for Int
impl From<[i64; 32]> for Int
[src]
impl From<[i64; 32]> for Int
impl PartialOrd for Int
[src]
impl PartialOrd for Int
fn partial_cmp(&self, rhs: &Int) -> Option<Ordering>
[src]
fn partial_cmp(&self, rhs: &Int) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, rhs: &Int) -> bool
[src]
fn lt(&self, rhs: &Int) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, rhs: &Int) -> bool
[src]
fn le(&self, rhs: &Int) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, rhs: &Int) -> bool
[src]
fn gt(&self, rhs: &Int) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, rhs: &Int) -> bool
[src]
fn ge(&self, rhs: &Int) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<S> Shl<S> for Int where
S: Into<ShiftAmount>,
[src]
impl<S> Shl<S> for Int where
S: Into<ShiftAmount>,
type Output = Int
The resulting type after applying the <<
operator.
fn shl(self, shift_amount: S) -> Self::Output
[src]
fn shl(self, shift_amount: S) -> Self::Output
Performs the <<
operation.
impl<S> Shr<S> for Int where
S: Into<ShiftAmount>,
[src]
impl<S> Shr<S> for Int where
S: Into<ShiftAmount>,
type Output = Int
The resulting type after applying the >>
operator.
fn shr(self, shift_amount: S) -> Self::Output
[src]
fn shr(self, shift_amount: S) -> Self::Output
Performs the >>
operation.
impl<S> ShlAssign<S> for Int where
S: Into<ShiftAmount>,
[src]
impl<S> ShlAssign<S> for Int where
S: Into<ShiftAmount>,
fn shl_assign(&mut self, shift_amount: S)
[src]
fn shl_assign(&mut self, shift_amount: S)
Performs the <<=
operation.
impl<S> ShrAssign<S> for Int where
S: Into<ShiftAmount>,
[src]
impl<S> ShrAssign<S> for Int where
S: Into<ShiftAmount>,
fn shr_assign(&mut self, shift_amount: S)
[src]
fn shr_assign(&mut self, shift_amount: S)
Performs the >>=
operation.
impl Not for Int
[src]
impl Not for Int
type Output = Int
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
fn not(self) -> Self::Output
Performs the unary !
operation.
impl<'a> BitAnd<&'a Int> for Int
[src]
impl<'a> BitAnd<&'a Int> for Int
type Output = Int
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Int) -> Self::Output
[src]
fn bitand(self, rhs: &'a Int) -> Self::Output
Performs the &
operation.
impl<'a, 'b> BitAnd<&'a Int> for &'b Int
[src]
impl<'a, 'b> BitAnd<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Int) -> Self::Output
[src]
fn bitand(self, rhs: &'a Int) -> Self::Output
Performs the &
operation.
impl<'a, 'b> BitAnd<&'a Int> for &'b mut Int
[src]
impl<'a, 'b> BitAnd<&'a Int> for &'b mut Int
type Output = Int
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Int) -> Self::Output
[src]
fn bitand(self, rhs: &'a Int) -> Self::Output
Performs the &
operation.
impl<'a> BitOr<&'a Int> for Int
[src]
impl<'a> BitOr<&'a Int> for Int
type Output = Int
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitor(self, rhs: &'a Int) -> Self::Output
Performs the |
operation.
impl<'a, 'b> BitOr<&'a Int> for &'b Int
[src]
impl<'a, 'b> BitOr<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitor(self, rhs: &'a Int) -> Self::Output
Performs the |
operation.
impl<'a, 'b> BitOr<&'a Int> for &'b mut Int
[src]
impl<'a, 'b> BitOr<&'a Int> for &'b mut Int
type Output = Int
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitor(self, rhs: &'a Int) -> Self::Output
Performs the |
operation.
impl<'a> BitXor<&'a Int> for Int
[src]
impl<'a> BitXor<&'a Int> for Int
type Output = Int
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitxor(self, rhs: &'a Int) -> Self::Output
Performs the ^
operation.
impl<'a, 'b> BitXor<&'a Int> for &'b Int
[src]
impl<'a, 'b> BitXor<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitxor(self, rhs: &'a Int) -> Self::Output
Performs the ^
operation.
impl<'a, 'b> BitXor<&'a Int> for &'b mut Int
[src]
impl<'a, 'b> BitXor<&'a Int> for &'b mut Int
type Output = Int
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a Int) -> Self::Output
[src]
fn bitxor(self, rhs: &'a Int) -> Self::Output
Performs the ^
operation.
impl<'a> BitAndAssign<&'a Int> for Int
[src]
impl<'a> BitAndAssign<&'a Int> for Int
fn bitand_assign(&mut self, rhs: &'a Int)
[src]
fn bitand_assign(&mut self, rhs: &'a Int)
Performs the &=
operation.
impl<'a> BitOrAssign<&'a Int> for Int
[src]
impl<'a> BitOrAssign<&'a Int> for Int
fn bitor_assign(&mut self, rhs: &'a Int)
[src]
fn bitor_assign(&mut self, rhs: &'a Int)
Performs the |=
operation.
impl<'a> BitXorAssign<&'a Int> for Int
[src]
impl<'a> BitXorAssign<&'a Int> for Int
fn bitxor_assign(&mut self, rhs: &'a Int)
[src]
fn bitxor_assign(&mut self, rhs: &'a Int)
Performs the ^=
operation.
impl Neg for Int
[src]
impl Neg for Int
type Output = Int
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl<'a> Neg for &'a Int
[src]
impl<'a> Neg for &'a Int
type Output = Int
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl<'a> Neg for &'a mut Int
[src]
impl<'a> Neg for &'a mut Int
type Output = &'a mut Int
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl<'a> Add<&'a Int> for Int
[src]
impl<'a> Add<&'a Int> for Int
type Output = Int
The resulting type after applying the +
operator.
fn add(self, rhs: &'a Int) -> Self::Output
[src]
fn add(self, rhs: &'a Int) -> Self::Output
Performs the +
operation.
impl<'a, 'b> Add<&'a Int> for &'b Int
[src]
impl<'a, 'b> Add<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the +
operator.
fn add(self, rhs: &'a Int) -> Self::Output
[src]
fn add(self, rhs: &'a Int) -> Self::Output
Performs the +
operation.
impl<'a> AddAssign<&'a Int> for Int
[src]
impl<'a> AddAssign<&'a Int> for Int
fn add_assign(&mut self, rhs: &'a Int)
[src]
fn add_assign(&mut self, rhs: &'a Int)
Performs the +=
operation.
impl<'a> Sub<&'a Int> for Int
[src]
impl<'a> Sub<&'a Int> for Int
type Output = Int
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Int) -> Self::Output
[src]
fn sub(self, rhs: &'a Int) -> Self::Output
Performs the -
operation.
impl<'a, 'b> Sub<&'a Int> for &'b Int
[src]
impl<'a, 'b> Sub<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Int) -> Self::Output
[src]
fn sub(self, rhs: &'a Int) -> Self::Output
Performs the -
operation.
impl<'a> SubAssign<&'a Int> for Int
[src]
impl<'a> SubAssign<&'a Int> for Int
fn sub_assign(&mut self, rhs: &'a Int)
[src]
fn sub_assign(&mut self, rhs: &'a Int)
Performs the -=
operation.
impl<'a> Mul<&'a Int> for Int
[src]
impl<'a> Mul<&'a Int> for Int
type Output = Int
The resulting type after applying the *
operator.
fn mul(self, rhs: &'a Int) -> Self::Output
[src]
fn mul(self, rhs: &'a Int) -> Self::Output
Performs the *
operation.
impl<'a, 'b> Mul<&'a Int> for &'b Int
[src]
impl<'a, 'b> Mul<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the *
operator.
fn mul(self, rhs: &'a Int) -> Self::Output
[src]
fn mul(self, rhs: &'a Int) -> Self::Output
Performs the *
operation.
impl<'a> MulAssign<&'a Int> for Int
[src]
impl<'a> MulAssign<&'a Int> for Int
fn mul_assign(&mut self, rhs: &'a Int)
[src]
fn mul_assign(&mut self, rhs: &'a Int)
Performs the *=
operation.
impl<'a> Div<&'a Int> for Int
[src]
impl<'a> Div<&'a Int> for Int
type Output = Int
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Int) -> Self::Output
[src]
fn div(self, rhs: &'a Int) -> Self::Output
Performs the /
operation.
impl<'a, 'b> Div<&'a Int> for &'b Int
[src]
impl<'a, 'b> Div<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Int) -> Self::Output
[src]
fn div(self, rhs: &'a Int) -> Self::Output
Performs the /
operation.
impl<'a> DivAssign<&'a Int> for Int
[src]
impl<'a> DivAssign<&'a Int> for Int
fn div_assign(&mut self, rhs: &'a Int)
[src]
fn div_assign(&mut self, rhs: &'a Int)
Performs the /=
operation.
impl<'a> Rem<&'a Int> for Int
[src]
impl<'a> Rem<&'a Int> for Int
type Output = Int
The resulting type after applying the %
operator.
fn rem(self, rhs: &'a Int) -> Self::Output
[src]
fn rem(self, rhs: &'a Int) -> Self::Output
Performs the %
operation.
impl<'a, 'b> Rem<&'a Int> for &'b Int
[src]
impl<'a, 'b> Rem<&'a Int> for &'b Int
type Output = Int
The resulting type after applying the %
operator.
fn rem(self, rhs: &'a Int) -> Self::Output
[src]
fn rem(self, rhs: &'a Int) -> Self::Output
Performs the %
operation.
impl<'a> RemAssign<&'a Int> for Int
[src]
impl<'a> RemAssign<&'a Int> for Int
fn rem_assign(&mut self, rhs: &'a Int)
[src]
fn rem_assign(&mut self, rhs: &'a Int)
Performs the %=
operation.
impl Binary for Int
[src]
impl Binary for Int
impl Octal for Int
[src]
impl Octal for Int
impl LowerHex for Int
[src]
impl LowerHex for Int
impl UpperHex for Int
[src]
impl UpperHex for Int