pub struct Arbi { /* private fields */ }Expand description
Arbitrary Precision Integer type.
§Internal Representation
The internal representation of an Arbi integer consists of a boolean field
encoding whether or not the integer is negative, as well as a Vec of
Digits (an unsigned integer type) encoding the absolute value of the
integer with least significant digits first. A “digit” is a
base-Arbi::BASE digit (i.e. an integer in
\( [0, \text{Arbi::BASE} - 1] = [0, \text{Digit::MAX}] \)).
§Limits
Arbi::MAX_CAPACITY:Vecis limited toisize::MAXbytes in capacity. A digit has size in bytescore::mem::size_of::<Digit>(). The maximum capacity is thereforeisize::MAX / core::mem::size_of::<Digit>().Arbi::MAX_BITS: At maximum capacity,Arbi::MAX_BITSbits are available to represent the absolute value of theArbiinteger.
When resizing/reserving more space, if the needed space exceeds isize::MAX
in bytes, the Vec allocation methods currently used will panic to signal
capacity overflow. The Vec allocation methods also panic if the
allocator reports allocation failure. In practice, memory allocation
typically fails for less than isize::MAX in bytes.
In the future, we may choose to explicitly handle such errors to avoid a panic, where it makes sense.
§Panic
In general:
-
If an operation can panic, it will be clearly documented.
-
Operations typically only panic because they are enforcing consistency with the behavior of primitive integer types. For example, a division by zero panics. Similarly,
Arbi::from_str_radix()andArbi::to_string_radix()panic if theradixargument value is invalid, consistent with the built-in analogues.Arbi::from_str_base()andArbi::to_string_base()are equivalent, except that they do not panic on invalid bases. -
Because
Vecis limited toisize::MAXbytes in capacity, if an operation would lead to anArbirequiring more thanisize::MAXbytes in capacity, then the currentVecallocation methods used will panic. TheVecallocation methods also panic if the allocator reports allocation failure. In practice, memory allocation typically fails for less thanisize::MAXin bytes. -
Some operations, such as exponentiation, might know in advance that the result will need a capacity that will exceed
Vec’s limits. In such cases, the program will panic immediately, rather than allow it to run a long computation that is guaranteed to exhaust memory.
Implementations§
Source§impl Arbi
impl Arbi
Sourcepub fn assign_str_radix(
&mut self,
s: &str,
radix: u32,
) -> Result<(), ParseError>
pub fn assign_str_radix( &mut self, s: &str, radix: u32, ) -> Result<(), ParseError>
Assign the integer value the provided string represents to this Arbi
integer.
§Panic
Panics if radix is not in \( [2, 36] \). Use
Arbi::assign_str_base for a panic-free version.
§Examples
use arbi::{Arbi, ParseError};
let mut x = Arbi::with_capacity(10);
assert_eq!(x, 0);
match x.assign_str_radix("123456789", 10) {
Ok(_) => assert_eq!(x, 123456789),
Err(e) => match e {
ParseError::InvalidDigit => panic!("Found an invalid digit"),
ParseError::Empty => panic!("Found an empty string"),
},
}
if let Err(e) = x.assign_str_radix("7c2ecdfacad74e0f0101b", 16) {
panic!("Parsing error: {}", e);
}
assert_eq!(x, 0x7c2ecdfacad74e0f0101b_u128);The Arbi integer will remain in its original state if a parsing error
occurs:
use arbi::{Arbi, Assign, ParseError};
let mut x = Arbi::from(u128::MAX);
assert_eq!(x, u128::MAX);
match x.assign_str_radix("7c2ecdfacad74e0f0101b", 15) {
Ok(_) => panic!(),
Err(e) => {
assert!(matches!(e, ParseError::InvalidDigit));
assert_eq!(x, u128::MAX);
}
}Panics on invalid radix values
use arbi::Arbi;
let mut x = Arbi::with_capacity(5);
x.assign_str_radix("7c2ecdfacad74e0f0101b", 37);Example invalid strings
use arbi::{Arbi, ParseError};
let mut a = Arbi::zero();
assert!(matches!(
a.assign_str_radix(" - ", 10),
Err(ParseError::Empty)
));
assert!(matches!(
a.assign_str_radix("ffff", 10),
Err(ParseError::InvalidDigit)
));Sourcepub fn assign_str_base(&mut self, s: &str, base: Base) -> Result<(), ParseError>
pub fn assign_str_base(&mut self, s: &str, base: Base) -> Result<(), ParseError>
Assign the integer value the provided string represents to this Arbi
integer.
§Examples
use arbi::{
base::{DEC, HEX},
Arbi, ParseError,
};
let mut x = Arbi::with_capacity(10);
assert_eq!(x, 0);
match x.assign_str_base("123456789", DEC) {
Ok(_) => assert_eq!(x, 123456789),
Err(e) => match e {
ParseError::InvalidDigit => panic!("Found an invalid digit"),
ParseError::Empty => panic!("Found an empty string"),
},
}
if let Err(e) = x.assign_str_base("7c2ecdfacad74e0f0101b", HEX) {
panic!("Parsing error: {}", e);
}
assert_eq!(x, 0x7c2ecdfacad74e0f0101b_u128);The Arbi integer will remain in its original state if a parsing error
occurs:
use arbi::{Arbi, Base, ParseError};
let mut x = Arbi::from(u128::MAX);
assert_eq!(x, u128::MAX);
match x
.assign_str_base("7c2ecdfacad74e0f0101b", Base::try_from(15).unwrap())
{
Ok(_) => panic!(),
Err(e) => {
assert!(matches!(e, ParseError::InvalidDigit));
assert_eq!(x, u128::MAX);
}
}Example invalid strings:
use arbi::{base::DEC, Arbi, ParseError};
let mut a = Arbi::zero();
assert!(matches!(
a.assign_str_base(" - ", DEC),
Err(ParseError::Empty)
));
assert!(matches!(
a.assign_str_base("ffff", DEC),
Err(ParseError::InvalidDigit)
));Source§impl Arbi
impl Arbi
Sourcepub fn test_bit(&self, i: BitCount) -> bool
pub fn test_bit(&self, i: BitCount) -> bool
Test bit i (zero-based indexing) of the absolute value of this
integer.
§Examples
use arbi::Arbi;
// 11000000111001 (bit indices [0, 13])
let a = Arbi::from(12345);
assert_eq!(a.test_bit(0), true);
assert_eq!(a.test_bit(1), false);
assert_eq!(a.test_bit(5), true);
assert_eq!(a.test_bit(13), true);
// 14 is not in [0, size_bits()). Bits outside of this range are
// treated as false.
assert_eq!(a.test_bit(14), false);§Complexity
\( O(1) \)
Sourcepub fn set_bit(&mut self, i: BitCount) -> &mut Self
pub fn set_bit(&mut self, i: BitCount) -> &mut Self
Set bit i (zero-based indexing) of the absolute value of this integer,
leaving its sign unchanged.
§Examples
use arbi::Arbi;
// 11000000111001
let mut a = Arbi::from(12345);
a.set_bit(1);
// 11000000111011
assert_eq!(a, 12347);
a.set_bit(14);
// 111000000111011
assert_eq!(a, 28731);§Complexity
- \( O(1) \) when setting an existing bit.
- \( O(n) \) when setting a bit outside the current bit width, as this requires resizing.
Sourcepub fn clear_bit(&mut self, i: BitCount) -> &mut Self
pub fn clear_bit(&mut self, i: BitCount) -> &mut Self
Clear bit i (zero-based indexing) of the absolute value of this
integer, leaving its sign unchanged (unless it becomes zero from a
negative self).
§Examples
use arbi::Arbi;
// 11000000111001 (absolute value of -12345)
let mut a = Arbi::from(-12345);
a.clear_bit(0);
// 11000000111000
assert_eq!(a, -12344);
a.clear_bit(13);
// 1000000111000
assert_eq!(a, -4152);
// Does nothing, as bits outside of the field defined by the indices
// [0, size_bits()) are treated as 0.
a.clear_bit(13);
assert_eq!(a, -4152);§Complexity
\( O(1) \)
Sourcepub fn invert_bit(&mut self, i: BitCount) -> &mut Self
pub fn invert_bit(&mut self, i: BitCount) -> &mut Self
If the bit at zero-based index i of the absolute value of this integer
is 1, clear it to 0. Otherwise, set it to 1.
Please note that bits with indices outside of the range
[0, size_bits()) are considered 0. Thus, inverting a bit outside of
that range will set it to 1.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(0xf); // 0b1111
a.invert_bit(0); // 0b1110
assert_eq!(a, 0b1110);
a.invert_bit(4); // 0b11110
assert_eq!(a, 0b11110);§Complexity
- \( O(1) \) when inverting an existing bit (i.e. a bit with index in
[0, size_bits())). - \( O(n) \) otherwise.
Source§impl Arbi
impl Arbi
Sourcepub fn abs_diff(self, other: Self) -> Self
pub fn abs_diff(self, other: Self) -> Self
Computes the absolute difference between self and other.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::from(8000).abs_diff(Arbi::from(10000)), 2000);
assert_eq!(Arbi::from(-10000).abs_diff(Arbi::from(8000)), 18000);
assert_eq!(Arbi::from(-10000).abs_diff(Arbi::from(-11000)), 1000);§Complexity
\( O(n) \)
Sourcepub fn abs_diff_mut(&mut self, other: &Self)
pub fn abs_diff_mut(&mut self, other: &Self)
Computes the absolute difference between self and other.
§Examples
use arbi::{Arbi, Assign};
let mut a = Arbi::from(8000);
let b = Arbi::from(10000);
a.abs_diff_mut(&b);
assert_eq!(a, 2000);
a.assign(-10000);
let b = Arbi::from(8000);
a.abs_diff_mut(&b);
assert_eq!(a, 18000);
a.assign(-10000);
let b = Arbi::from(-11000);
a.abs_diff_mut(&b);
assert_eq!(a, 1000);§Complexity
\( O(n) \)
Sourcepub fn abs_diff_ref(&self, other: &Self) -> Self
pub fn abs_diff_ref(&self, other: &Self) -> Self
Computes the absolute difference between self and other.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::from(8000).abs_diff_ref(&Arbi::from(10000)), 2000);
assert_eq!(Arbi::from(-10000).abs_diff_ref(&Arbi::from(8000)), 18000);
assert_eq!(Arbi::from(-10000).abs_diff_ref(&Arbi::from(-11000)), 1000);§Complexity
\( O(n) \)
Source§impl Arbi
impl Arbi
Sourcepub fn count_ones(&self) -> u128
pub fn count_ones(&self) -> u128
Returns the number of ones in the binary representation of the absolute
value of self.
§Examples
use arbi::Arbi;
let a = Arbi::from(0b01001100u32);
assert_eq!(a.count_ones(), 3);
let max_u64 = Arbi::from(u64::MAX);
assert_eq!(max_u64.count_ones(), 64);
let zero = Arbi::zero();
assert_eq!(zero.count_ones(), 0);§Complexity
\( O(n) \)
Source§impl Arbi
impl Arbi
Sourcepub fn div_euclid_ref(&self, rhs: &Self) -> Arbi
pub fn div_euclid_ref(&self, rhs: &Self) -> Arbi
Calculates the quotient of Euclidean division of self by rhs.
§See also
div_euclid()for built-in integer types.Arbi::divrem_euclid_ref().
§Panics
This function will panic if rhs is 0.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(9);
let mut b = Arbi::from(5);
assert_eq!(a.div_euclid_ref(&b), 1);
b.negate_mut();
assert_eq!(a.div_euclid_ref(&b), -1);
a.negate_mut();
b.negate_mut();
assert_eq!(a.div_euclid_ref(&b), -2);
b.negate_mut();
assert_eq!(a.div_euclid_ref(&b), 2);Panics if rhs is zero:
use arbi::Arbi;
let num = Arbi::from(9);
let den = Arbi::zero();
num.div_euclid_ref(&den);§Complexity
\( O(m \cdot n) \)
Sourcepub fn rem_euclid_ref(&self, rhs: &Self) -> Arbi
pub fn rem_euclid_ref(&self, rhs: &Self) -> Arbi
Calculates the least nonnegative remainder of self (mod rhs).
§See also
rem_euclid()for built-in integer types.Arbi::divrem_euclid_ref().
§Panics
This function will panic if rhs is 0.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(9);
let mut b = Arbi::from(5);
assert_eq!(a.rem_euclid_ref(&b), 4);
b.negate_mut();
assert_eq!(a.rem_euclid_ref(&b), 4);
a.negate_mut();
b.negate_mut();
assert_eq!(a.rem_euclid_ref(&b), 1);
b.negate_mut();
assert_eq!(a.rem_euclid_ref(&b), 1);Panics if rhs is zero:
use arbi::Arbi;
let num = Arbi::from(9);
let den = Arbi::zero();
num.rem_euclid_ref(&den);§Complexity
\( O(m \cdot n) \)
Sourcepub fn divrem_euclid_ref(&self, rhs: &Self) -> (Arbi, Arbi)
pub fn divrem_euclid_ref(&self, rhs: &Self) -> (Arbi, Arbi)
Same as (self.div_euclid_ref(rhs), self.rem_euclid_ref(rhs)), but in
one pass.
§Panics
This function will panic if rhs is 0.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(9);
let mut b = Arbi::from(5);
let (quo, rem) = a.divrem_euclid_ref(&b);
assert!(quo == 1 && rem == 4);
b.negate_mut();
let (quo, rem) = a.divrem_euclid_ref(&b);
assert!(quo == -1 && rem == 4);
a.negate_mut();
b.negate_mut();
let (quo, rem) = a.divrem_euclid_ref(&b);
assert!(quo == -2 && rem == 1);
b.negate_mut();
let (quo, rem) = a.divrem_euclid_ref(&b);
assert!(quo == 2 && rem == 1);Panics if rhs is zero:
use arbi::Arbi;
let num = Arbi::from(9);
let den = Arbi::zero();
num.divrem_euclid_ref(&den);§Complexity
\( O(m \cdot n) \)
Source§impl Arbi
impl Arbi
Sourcepub fn from_le_bytes(bytes: &[u8]) -> Self
pub fn from_le_bytes(bytes: &[u8]) -> Self
Creates an Arbi integer from its representation as a byte array
in little endian, interpreted as a nonnegative integer.
If bytes is empty, Arbi::zero() is returned.
§Examples
use arbi::Arbi;
let bytes = [0x78, 0x56, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90];
let value = Arbi::from_le_bytes(&bytes);
assert_eq!(value, 0x9078563412345678_u64);
assert_eq!(value, u64::from_le_bytes(bytes));
let zero = Arbi::from_le_bytes(&[]);
assert_eq!(zero, 0);Sourcepub fn from_be_bytes(bytes: &[u8]) -> Self
pub fn from_be_bytes(bytes: &[u8]) -> Self
Creates an Arbi integer from its representation as a byte array
in big endian, interpreted as a nonnegative integer.
If bytes is empty, Arbi::zero() is returned.
§Examples
use arbi::Arbi;
let bytes = [0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78];
let value = Arbi::from_be_bytes(&bytes);
assert_eq!(value, 0x1234567812345678_u64);
assert_eq!(value, u64::from_be_bytes(bytes));
let zero = Arbi::from_be_bytes(&[]);
assert_eq!(zero, 0);Sourcepub fn from_le_bytes_signed(bytes: &[u8]) -> Self
pub fn from_le_bytes_signed(bytes: &[u8]) -> Self
Creates an Arbi integer from its representation as a byte array
in little endian, interpreted as a signed integer.
If bytes is empty, Arbi::zero() is returned.
§Examples
use arbi::Arbi;
// Positive
let bytes = [0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12];
let value = Arbi::from_le_bytes_signed(&bytes);
assert_eq!(value, 0x1234567812345678_i64);
assert_eq!(value, i64::from_le_bytes(bytes));
// Negative
let bytes = [0xb3, 0xb3, 0xb4, 0xb5, 0xb2, 0xb3, 0xb4, 0xb5];
let value = Arbi::from_le_bytes_signed(&bytes);
assert_eq!(value, i64::from_le_bytes(bytes));
// Zero
let bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
let value = Arbi::from_le_bytes_signed(&bytes);
assert_eq!(value, 0);
assert_eq!(value, i64::from_le_bytes(bytes));
let zero = Arbi::from_le_bytes_signed(&[]);
assert_eq!(zero, 0);Sourcepub fn from_be_bytes_signed(bytes: &[u8]) -> Self
pub fn from_be_bytes_signed(bytes: &[u8]) -> Self
Creates an Arbi integer from its representation as a byte array
in big endian, interpreted as a signed integer.
If bytes is empty, Arbi::zero() is returned.
§Examples
use arbi::Arbi;
// Positive
let bytes = [0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78];
let value = Arbi::from_be_bytes_signed(&bytes);
assert_eq!(value, 0x1234567812345678_i64);
assert_eq!(value, i64::from_be_bytes(bytes));
// Negative
let bytes = [0xb5, 0xb4, 0xb3, 0xb2, 0xb5, 0xb4, 0xb3, 0xb3];
let value = Arbi::from_be_bytes_signed(&bytes);
assert_eq!(value, i64::from_be_bytes(bytes));
// Zero
let bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
let value = Arbi::from_be_bytes_signed(&bytes);
assert_eq!(value, 0);
assert_eq!(value, i64::from_be_bytes(bytes));
let zero = Arbi::from_be_bytes_signed(&[]);
assert_eq!(zero, 0);Sourcepub fn from_ne_bytes(bytes: &[u8]) -> Self
pub fn from_ne_bytes(bytes: &[u8]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness, interpreted as a nonnegative integer.
§Examples
use arbi::Arbi;
let bytes = if cfg!(target_endian = "big") {
[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]
} else {
[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]
};
let a = Arbi::from_ne_bytes(&bytes);
assert_eq!(a, 0x1234567890123456_i64);
assert_eq!(a, i64::from_ne_bytes(bytes));Sourcepub fn from_ne_bytes_signed(bytes: &[u8]) -> Self
pub fn from_ne_bytes_signed(bytes: &[u8]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness, interpreted as a signed integer.
§Examples
use arbi::Arbi;
let bytes = if cfg!(target_endian = "big") {
[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]
} else {
[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]
};
let a = Arbi::from_ne_bytes_signed(&bytes);
assert_eq!(a, 0x1234567890123456_i64);
assert_eq!(a, i64::from_ne_bytes(bytes));Source§impl Arbi
impl Arbi
Sourcepub fn ilog(self, base: u32) -> BitCount
pub fn ilog(self, base: u32) -> BitCount
Returns the base-base logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero, or if
base is less than 2.
§Examples
use arbi::Arbi;
let a = Arbi::from(10);
assert_eq!(a.ilog(8), 1);Nonpositive values panic:
use arbi::Arbi;
let zero = Arbi::zero();
zero.ilog(8);use arbi::Arbi;
let minus_one = Arbi::neg_one();
minus_one.ilog(8);A base less than 2 causes a panic
use arbi::Arbi;
let a = Arbi::from(4);
a.ilog(1);Sourcepub fn ilog_mut(&mut self, base: u32) -> BitCount
pub fn ilog_mut(&mut self, base: u32) -> BitCount
Returns the base-base logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero, or if
base is less than 2.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(10);
a.ilog_mut(8);
assert_eq!(a, 1);Nonpositive values panic:
use arbi::Arbi;
let mut zero = Arbi::zero();
zero.ilog_mut(8);use arbi::Arbi;
let mut minus_one = Arbi::neg_one();
minus_one.ilog_mut(8);A base less than 2 causes a panic
use arbi::Arbi;
let mut a = Arbi::from(4);
a.ilog_mut(1);Sourcepub fn ilog_ref(&self, base: u32) -> BitCount
pub fn ilog_ref(&self, base: u32) -> BitCount
Returns the base-base logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero, or if
base is less than 2.
§Examples
use arbi::Arbi;
let a = Arbi::from(10);
assert_eq!(a.ilog_ref(8), 1);Nonpositive values panic:
use arbi::Arbi;
let zero = Arbi::zero();
zero.ilog_ref(8);use arbi::Arbi;
let minus_one = Arbi::neg_one();
minus_one.ilog_ref(8);A base less than 2 causes a panic
use arbi::Arbi;
let a = Arbi::from(4);
a.ilog_ref(1);Source§impl Arbi
impl Arbi
Sourcepub fn ilog10(self) -> BitCount
pub fn ilog10(self) -> BitCount
Returns the base 10 logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero.
§Examples
use arbi::Arbi;
let a = Arbi::from(10);
assert_eq!(a.ilog10(), 1);Nonpositive values panic:
use arbi::Arbi;
let zero = Arbi::zero();
zero.ilog10();use arbi::Arbi;
let neg_one = Arbi::neg_one();
neg_one.ilog10();Sourcepub fn ilog10_mut(&mut self) -> BitCount
pub fn ilog10_mut(&mut self) -> BitCount
Returns the base 10 logarithm of the number, rounded down.
The value of self will compare equal to the return value.
§Panics
This function will panic if self is less than or equal to zero.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(10);
assert_eq!(a.ilog10_mut(), 1);
assert_eq!(a, 1);Nonpositive values panic:
use arbi::Arbi;
let mut zero = Arbi::zero();
zero.ilog10_mut();use arbi::Arbi;
let mut minus_one = Arbi::neg_one();
minus_one.ilog10_mut();Sourcepub fn ilog10_ref(&self) -> BitCount
pub fn ilog10_ref(&self) -> BitCount
Returns the base 10 logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero.
§Examples
use arbi::Arbi;
let a = Arbi::from(10);
assert_eq!(a.ilog10_ref(), 1);Nonpositive values panic:
use arbi::Arbi;
let zero = Arbi::zero();
zero.ilog10_ref();use arbi::Arbi;
let minus_one = Arbi::neg_one();
minus_one.ilog10_ref();Source§impl Arbi
impl Arbi
Sourcepub fn ilog2(&self) -> BitCount
pub fn ilog2(&self) -> BitCount
Returns the base 2 logarithm of the number, rounded down.
§Panics
This function will panic if self is less than or equal to zero.
§Examples
use arbi::{Arbi, BitCount};
let a = Arbi::from(2);
assert_eq!(a.ilog2(), 1);
assert_eq!(2_i32.ilog2(), 1);
let b = Arbi::from(123456789_i32);
assert_eq!(b.ilog2(), 26);
assert_eq!(123456789_i32.ilog2(), 26);
let c = Arbi::from(u128::MAX);
assert_eq!(c.ilog2(), u128::MAX.ilog2() as BitCount);This function will panic if self is zero or negative:
use arbi::Arbi;
let a = Arbi::zero();
a.ilog2();use arbi::Arbi;
let a = Arbi::neg_one();
a.ilog2();§Complexity
\( O(1) \)
Source§impl Arbi
impl Arbi
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Source§impl Arbi
impl Arbi
Sourcepub fn is_power_of_two(&self) -> bool
pub fn is_power_of_two(&self) -> bool
Returns true if and only if |self| == 2^k for some k.
That is, return true iff the absolute value of this integer is a power
of 2.
§Examples
use arbi::Arbi;
let one = Arbi::one();
assert!(one.is_power_of_two());
assert!(1u32.is_power_of_two());
let two = Arbi::from(2);
assert!(two.is_power_of_two());
assert!(2u32.is_power_of_two());
let a = Arbi::from(32);
assert!(a.is_power_of_two());
assert!(32u32.is_power_of_two());
let b = Arbi::from(30);
assert!(!b.is_power_of_two());
assert!(!(30u32.is_power_of_two()));
let base = Arbi::from(Arbi::BASE);
assert!(base.is_power_of_two());Source§impl Arbi
impl Arbi
Sourcepub fn leading_ones(&self) -> u128
pub fn leading_ones(&self) -> u128
Returns the number of leading ones in the binary representation of the
absolute value of self.
§Examples
use arbi::Arbi;
let zero = Arbi::zero();
assert_eq!(zero.leading_ones(), 0);
let a = Arbi::from(u128::MAX);
assert_eq!(a.leading_ones(), 128);
let b = Arbi::from(u128::MAX - 1);
assert_eq!(b.leading_ones(), 127);§Complexity
\( O(n) \)
Source§impl Arbi
impl Arbi
Sourcepub fn reverse_bits(self) -> Self
pub fn reverse_bits(self) -> Self
Reverses the order of bits in the absolute value of the integer.
The least significant bit becomes the most significant bit, second least significant bit becomes second most-significant bit, etc.
The sign remains unchanged.
§Examples
use arbi::Arbi;
let a = Arbi::from(0x12345678_u32);
assert_eq!(a.reverse_bits(), 0x12345678_u32.reverse_bits());§Complexity
\( O(n) \)
Sourcepub fn reverse_bits_mut(&mut self)
pub fn reverse_bits_mut(&mut self)
Reverses the order of bits in the absolute value of the integer.
The least significant bit becomes the most significant bit, second least significant bit becomes second most-significant bit, etc.
The sign remains unchanged.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(0x12345678_u32);
a.reverse_bits_mut();
assert_eq!(a, 0x12345678_u32.reverse_bits());Sourcepub fn reverse_bits_ref(&self) -> Self
pub fn reverse_bits_ref(&self) -> Self
Reverses the order of bits in the absolute value of the integer.
The least significant bit becomes the most significant bit, second least significant bit becomes second most-significant bit, etc.
The sign remains unchanged.
§Examples
use arbi::Arbi;
let a = Arbi::from(0x12345678_u32);
let b: Arbi = a.reverse_bits_ref();
assert_eq!(b, 0x12345678_u32.reverse_bits());Source§impl Arbi
impl Arbi
Sourcepub fn signum(&self) -> i32
pub fn signum(&self) -> i32
Returns a number representing the sign of self.
0if the number if zero.1if the number if positive.-1if the number is negative.
§Examples
use arbi::Arbi;
let zero = Arbi::zero();
assert_eq!(zero.signum(), 0);
assert_eq!(0i32.signum(), 0);
let one = Arbi::one();
assert_eq!(one.signum(), 1);
assert_eq!(1i32.signum(), 1);
let neg_one = Arbi::neg_one();
assert_eq!(neg_one.signum(), -1);
assert_eq!((-1i32).signum(), -1);§Complexity
\( O(1) \)
Source§impl Arbi
impl Arbi
Sourcepub fn swap_bytes(self) -> Self
pub fn swap_bytes(self) -> Self
Sourcepub fn swap_bytes_mut(&mut self)
pub fn swap_bytes_mut(&mut self)
Reverses the byte order of the absolute value of the integer.
The sign remains unchanged.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(0x12345678_u32);
a.swap_bytes_mut();
assert_eq!(a, 0x78563412);Sourcepub fn swap_bytes_ref(&self) -> Self
pub fn swap_bytes_ref(&self) -> Self
Reverses the byte order of the absolute value of the integer.
The sign remains unchanged.
§Examples
use arbi::Arbi;
let a = Arbi::from(0x12345678_u32);
assert_eq!(a.swap_bytes_ref(), 0x78563412);Source§impl Arbi
impl Arbi
Sourcepub fn to_le_bytes(&self) -> Vec<u8>
pub fn to_le_bytes(&self) -> Vec<u8>
Returns the memory representation of this integer as a byte Vec in
little-endian byte order, interpreted as a nonnegative integer.
§Examples
use arbi::Arbi;
let a = Arbi::from(0x1234567890123456_u64);
let bytes = a.to_le_bytes();
assert_eq!(bytes, [0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]);
assert_eq!(bytes, 0x1234567890123456_u64.to_le_bytes());§Complexity
\( O(n) \)
Sourcepub fn to_be_bytes(&self) -> Vec<u8>
pub fn to_be_bytes(&self) -> Vec<u8>
Returns the memory representation of this integer as a byte Vec in
big-endian (network) byte order, interpreted as a nonnegative integer.
§Examples
use arbi::Arbi;
let a = Arbi::from(0x1234567890123456_u64);
let bytes = a.to_be_bytes();
assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]);
assert_eq!(bytes, 0x1234567890123456_u64.to_be_bytes());§Complexity
\( O(n) \)
Sourcepub fn to_le_bytes_signed(&self) -> Vec<u8>
pub fn to_le_bytes_signed(&self) -> Vec<u8>
Returns the memory representation of this integer as a byte Vec in
little-endian byte order, interpreted as a signed integer.
§Examples
use arbi::Arbi;
let a = Arbi::from(-0x1234567890123456_i64);
let bytes = a.to_le_bytes_signed();
assert_eq!(bytes, (-0x1234567890123456_i64).to_le_bytes());§Complexity
\( O(n) \)
Sourcepub fn to_be_bytes_signed(&self) -> Vec<u8>
pub fn to_be_bytes_signed(&self) -> Vec<u8>
Returns the memory representation of this integer as a byte Vec in
big-endian (network) byte order, interpreted as a signed integer.
§Examples
use arbi::Arbi;
let a = Arbi::from(-0x1234567890123456_i64);
let bytes = a.to_be_bytes_signed();
assert_eq!(bytes, (-0x1234567890123456_i64).to_be_bytes());§Complexity
\( O(n) \)
Sourcepub fn to_ne_bytes(&self) -> Vec<u8>
pub fn to_ne_bytes(&self) -> Vec<u8>
Source§impl Arbi
impl Arbi
Sourcepub fn trailing_ones(&self) -> u128
pub fn trailing_ones(&self) -> u128
Returns the number of trailing ones in the binary representation of the
absolute value of self.
§Examples
use arbi::Arbi;
let zero = Arbi::zero();
assert_eq!(zero.trailing_ones(), 0);
let a = Arbi::from(u128::MAX);
assert_eq!(a.trailing_ones(), 128);
let b = Arbi::from(u128::MAX - 1);
assert_eq!(b.trailing_ones(), 0);§Complexity
\( O(n) \)
Source§impl Arbi
impl Arbi
Sourcepub const MAX_CAPACITY: usize = 536_870_911usize
pub const MAX_CAPACITY: usize = 536_870_911usize
Maximum capacity for the internal vector of digits.
Vec is limited to isize::MAX bytes in capacity. A digit has size
in bytes core::mem::size_of::<Digit>(). The maximum capacity is
therefore isize::MAX / core::mem::size_of::<Digit>().
Sourcepub const MAX_BITS: BitCount = 17_179_869_152u128
pub const MAX_BITS: BitCount = 17_179_869_152u128
Maximum capacity for the internal vector of digits, in terms of bits.
This represents the number of bits that can be used to represent the absolute value of the integer when the internal digit vector is at maximum capacity.
This is Arbi::MAX_CAPACITY * Digit::BITS.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the total number of elements the internal digit vector can hold without reallocating.
§Examples
use arbi::{Arbi, Assign};
let zero = Arbi::zero();
assert_eq!(zero.capacity(), 0);
let mut b = Arbi::with_capacity(10);
assert_eq!(b.capacity(), 10);
b.assign(u64::MAX); // no memory allocation needed
assert_eq!(b, u64::MAX);§Complexity
\( O(1) \)
Sourcepub fn capacity_bits(&self) -> BitCount
pub fn capacity_bits(&self) -> BitCount
Return the total number of bits the current capacity can hold to represent the absolute value of this integer.
§Examples
use arbi::{Arbi, BitCount, Digit};
let zero = Arbi::zero();
assert_eq!(zero.capacity_bits(), 0);
let a = Arbi::with_capacity_bits(Digit::BITS as BitCount);
assert!(a.capacity_bits() >= Digit::BITS as BitCount);§Complexitys
\( O(1) \)
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct a new Arbi integer with at least the specified capacity, in
terms of Digits.
The integer’s value will be 0.
§Examples
use arbi::Arbi;
let a = Arbi::with_capacity(10);
assert_eq!(a.capacity(), 10);
assert_eq!(a, 0);Panics if the new capacity exceeds Arbi::MAX_CAPACITY digits:
use arbi::Arbi;
let a = Arbi::with_capacity(Arbi::MAX_CAPACITY + 1);§Panic
Panics if the new capacity exceeds isize::MAX bytes (or
Arbi::MAX_CAPACITY digits) or if the allocator reports an allocation
failure.
Sourcepub fn with_capacity_bits(capacity: BitCount) -> Self
pub fn with_capacity_bits(capacity: BitCount) -> Self
Construct a new Arbi integer with at least the specified capacity, in
terms of bits.
The integer’s value will be 0.
§Examples
use arbi::{Arbi, BitCount, Digit};
let a = Arbi::with_capacity_bits(Digit::BITS as BitCount - 1);
assert_eq!(a.capacity(), 1);
assert_eq!(a, 0);
let a = Arbi::with_capacity_bits(Digit::BITS as BitCount);
assert_eq!(a.capacity(), 1);
let a = Arbi::with_capacity_bits(Digit::BITS as BitCount + 1);
assert_eq!(a.capacity(), 2);Panics if the new capacity in bits exceeds Arbi::MAX_BITS bits:
use arbi::Arbi;
// Panics with message: "New capacity exceeds `isize::MAX` bytes".
let a = Arbi::with_capacity_bits(Arbi::MAX_BITS + 1);Note that, in practice, while the theoretical limit for the capacity
of a Vec in bytes is isize::MAX, memory allocation failures
typically happen for less.
§Panic
Panics if the new capacity exceeds isize::MAX bytes (or
Arbi::MAX_BITS digits) or if the allocator reports an allocation
failure.
Source§impl Arbi
impl Arbi
Sourcepub fn divrem(&self, other: &Arbi) -> (Arbi, Arbi)
pub fn divrem(&self, other: &Arbi) -> (Arbi, Arbi)
Computes both the quotient and remainder of division of this Arbi
object by another Arbi object and returns both the quotient and the
remainder as a pair.
In Rust, integer division rounds towards zero
and given remainder = dividend % divisor, remainder will have the
same sign as the dividend. The behavior of division in this crate is
consistent with that of division of integer primitive types.
Generally speaking, division algorithms calculate both the quotient and remainder simultaneously. If you need both, it is best to ask for both in one step rather than use the / and % operators in turn.
§Parameters
other: The divisor.
§Panic
§Return
A pair of Arbi integers where the first element is the quotient and
the second element is the remainder.
§Examples
use arbi::{Arbi, Assign};
let num = Arbi::from_str_radix(
"100000000000000000000000000000000000000000000000000",
16,
)
.unwrap();
let mut den =
Arbi::from_str_radix("40000000000000000000000000000000000000", 16)
.unwrap();
let (quo, rem) = num.divrem(&den);
assert_eq!(quo, 1125899906842624_u64);
assert_eq!(rem, 0);
if let Err(e) = den.assign_str_radix(
"-10b67ec03f7d363506c60c8c877b6f92be8f41518c16aa3187",
16,
) {
panic!("Parse error: {}", e);
}
let (quo, rem) = num.divrem(&den);
let expected_rem = Arbi::from_str_radix(
"54e92bc47a9d2e49a6543c40fc47666d59b2c38caac071917",
16,
)
.unwrap();
assert_eq!(quo, -15);
assert_eq!(rem, expected_rem);
// We can also use the / and % operators in turn to get the same result,
// but that would involve two passes through the division algorithm.
assert_eq!(&num / &den, -15);
assert_eq!(&num % &den, expected_rem);Dividing an Arbi integer by zero panics:
use arbi::Arbi;
let x = Arbi::from_str_radix("123456789", 10).unwrap();
let (quo, rem) = x.divrem(&Arbi::zero());Dividing a primitive integer value by zero panics:
#![allow(unconditional_panic)]
let zero = 0;
let x = -123456789 / zero;§Complexity
\( O(m \cdot n) \)
Source§impl Arbi
impl Arbi
Sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseError>
Equivalent to Arbi::from_str_base(), but panics if the base is
invalid (i.e. not in \( [2, 36] \)).
§Examples
use arbi::{Arbi, Base};
let x = Arbi::from_str_radix("987654321", 10).unwrap();
assert_eq!(x, 987654321);Sourcepub fn from_str_base(s: &str, base: Base) -> Result<Self, ParseError>
pub fn from_str_base(s: &str, base: Base) -> Result<Self, ParseError>
Construct an integer from a string representing a base-base integer.
Allows leading whitespace and/or a plus/minus sign before the first
base-base digit. base must be an integer in \( [2, 36] \).
Trailing whitespace is ignored.
§Examples
use arbi::{base::DEC, Arbi};
let x = Arbi::from_str_base("987654321", DEC).unwrap();
assert_eq!(x, 987654321);Source§impl Arbi
impl Arbi
Source§impl Arbi
impl Arbi
Sourcepub fn negate_mut(&mut self)
pub fn negate_mut(&mut self)
Sourcepub fn negate_ref(&self) -> Self
pub fn negate_ref(&self) -> Self
Source§impl Arbi
impl Arbi
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Return an Arbi integer with value 0.
No memory allocation occurs.
Arbi::new(), Arbi::zero(), and Arbi::default() are
equivalent, except that Arbi::default() is not const.
§Examples
use arbi::Arbi;
let zero = Arbi::new();
assert_eq!(zero, 0);§Complexity
\( O(1) \)
Source§impl Arbi
impl Arbi
Sourcepub fn sign(&self) -> Ordering
pub fn sign(&self) -> Ordering
Return an Ordering indicating the sign of the number: Ordering::Less
for negative, Ordering::Equal for zero, Ordering::Greater for
positive.
§Examples
use arbi::Arbi;
use core::cmp::Ordering;
let neg = Arbi::from(-123456789);
let zer = Arbi::zero();
let pos = Arbi::from(123456789);
assert_eq!(neg.sign(), Ordering::Less);
assert_eq!(zer.sign(), Ordering::Equal);
assert_eq!(pos.sign(), Ordering::Greater);§Complexity
\( O(1) \)
Source§impl Arbi
impl Arbi
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Return the number of Digits used to represent the absolute value of
this integer.
Instance represents 0 if and only if size() == 0.
§Examples
use arbi::{Arbi, Digit};
let zero = Arbi::zero();
assert_eq!(zero.size(), 0);
let mut a = Arbi::from(Digit::MAX);
assert_eq!(a.size(), 1);
a.incr();
assert_eq!(a.size(), 2);§Complexity
\( O(1) \)
Sourcepub fn size_bits(&self) -> BitCount
pub fn size_bits(&self) -> BitCount
Return the number of bits needed to represent the absolute value of this integer.
Instance represents 0 if and only if size_bits() == 0.
§Examples
use arbi::{Arbi, BitCount, Digit};
let zero = Arbi::zero();
assert_eq!(zero.size_bits(), 0);
let mut a = Arbi::from(Digit::MAX);
assert_eq!(a.size_bits(), Digit::BITS as BitCount);
a.incr();
assert_eq!(a.size_bits(), Digit::BITS as BitCount + 1);§Complexity
\( O(1) \)
Sourcepub fn size_base(self, base: u32) -> BitCount
pub fn size_base(self, base: u32) -> BitCount
Return the number of base-base digits needed to represent the absolute
value of this integer.
Instance represents 0 if and only if size_base() == 0.
§Panics
This function will panic if base is less than or equal to 1.
§Examples
use arbi::Arbi;
let zero = Arbi::zero();
assert_eq!(zero.size_base(10), 0);
let one = Arbi::one();
assert_eq!(one.size_base(10), 1);
let a = Arbi::from_str_radix("123456789", 10).unwrap();
assert_eq!(a.size_base(10), 9);Panics on a base less than or equal to 1:
use arbi::Arbi;
let a = Arbi::from(1234);
a.size_base(1);Sourcepub fn size_base_mut(&mut self, base: u32) -> BitCount
pub fn size_base_mut(&mut self, base: u32) -> BitCount
Return the number of base-base digits needed to represent the absolute
value of this integer.
Instance represents 0 if and only if size_base_mut() == 0.
The value of self will compare equal to the return value.
§Panics
This function will panic if base is less than or equal to 1.
§Examples
use arbi::Arbi;
let mut zero = Arbi::zero();
assert_eq!(zero.size_base_mut(10), 0);
assert_eq!(zero, 0);
let mut one = Arbi::one();
assert_eq!(one.size_base_mut(10), 1);
assert_eq!(one, 1);
let mut a = Arbi::from_str_radix("123456789", 10).unwrap();
assert_eq!(a.size_base_mut(10), 9);
assert_eq!(a, 9);Panics on a base less than or equal to 1:
use arbi::Arbi;
let mut a = Arbi::from(1234);
a.size_base_mut(1);Sourcepub fn size_base_ref(&self, base: u32) -> BitCount
pub fn size_base_ref(&self, base: u32) -> BitCount
Return the number of base-base digits needed to represent the absolute
value of this integer.
Instance represents 0 if and only if size_base_ref() == 0.
§Panics
This function will panic if base is less than or equal to 1.
§Examples
use arbi::Arbi;
let zero = Arbi::zero();
assert_eq!(zero.size_base_ref(10), 0);
let one = Arbi::one();
assert_eq!(one.size_base_ref(10), 1);
let a = Arbi::from_str_radix("123456789", 10).unwrap();
assert_eq!(a.size_base_ref(10), 9);Panics on a base less than or equal to 1:
use arbi::Arbi;
let a = Arbi::from(1234);
a.size_base_ref(1);Source§impl Arbi
impl Arbi
Sourcepub fn to_f64(&self) -> f64
pub fn to_f64(&self) -> f64
Convert this integer to a floating-point value.
The semantics of this function are consistent with Rust’s built-in behavior for casting from an integer to a float.
§Examples
use arbi::{Arbi, Pow};
let a = Arbi::from(-987654321);
assert_eq!(a.to_f64(), -987654321.0);
let b = Arbi::from(1_u64 << 32);
assert_ne!((&b).pow(31_usize).to_f64(), f64::INFINITY);
assert_eq!((&b).pow(32_usize).to_f64(), f64::INFINITY);§Complexity
\( O(1) \)
Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_i8(&self) -> i8
pub fn wrapping_to_i8(&self) -> i8
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_i8(&self) -> Option<i8>
pub fn checked_to_i8(&self) -> Option<i8>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_i16(&self) -> i16
pub fn wrapping_to_i16(&self) -> i16
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_i16(&self) -> Option<i16>
pub fn checked_to_i16(&self) -> Option<i16>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_i32(&self) -> i32
pub fn wrapping_to_i32(&self) -> i32
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_i32(&self) -> Option<i32>
pub fn checked_to_i32(&self) -> Option<i32>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_i64(&self) -> i64
pub fn wrapping_to_i64(&self) -> i64
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_i64(&self) -> Option<i64>
pub fn checked_to_i64(&self) -> Option<i64>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_i128(&self) -> i128
pub fn wrapping_to_i128(&self) -> i128
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_i128(&self) -> Option<i128>
pub fn checked_to_i128(&self) -> Option<i128>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_isize(&self) -> isize
pub fn wrapping_to_isize(&self) -> isize
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_isize(&self) -> Option<isize>
pub fn checked_to_isize(&self) -> Option<isize>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Sourcepub fn fits_isize(&self) -> bool
pub fn fits_isize(&self) -> bool
Return true if this integer fits in this primitive integer type,
false otherwise.
§Examples
use arbi::Arbi;
let mut x = Arbi::from(u8::MAX);
assert!(x.fits_u8());
x.incr();
assert!(!x.fits_u8());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_u8(&self) -> u8
pub fn wrapping_to_u8(&self) -> u8
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_u8(&self) -> Option<u8>
pub fn checked_to_u8(&self) -> Option<u8>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_u16(&self) -> u16
pub fn wrapping_to_u16(&self) -> u16
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_u16(&self) -> Option<u16>
pub fn checked_to_u16(&self) -> Option<u16>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_u32(&self) -> u32
pub fn wrapping_to_u32(&self) -> u32
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_u32(&self) -> Option<u32>
pub fn checked_to_u32(&self) -> Option<u32>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_u64(&self) -> u64
pub fn wrapping_to_u64(&self) -> u64
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_u64(&self) -> Option<u64>
pub fn checked_to_u64(&self) -> Option<u64>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_u128(&self) -> u128
pub fn wrapping_to_u128(&self) -> u128
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_u128(&self) -> Option<u128>
pub fn checked_to_u128(&self) -> Option<u128>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Source§impl Arbi
impl Arbi
Sourcepub fn wrapping_to_usize(&self) -> usize
pub fn wrapping_to_usize(&self) -> usize
Convert this Arbi integer to a primitive integer type value.
This is “wrapping”.
§Note
From<Arbi>andFrom<&Arbi>are implemented for each primitive integral type and has the same semantics. See, for example,impl From<&Arbi> for i32.- In Rust, casting from a larger primitive integer type to a smaller integer type truncates. This function has the same semantics.
§Return
Return the unique value of this target primitive integer type that is
congruent to the Arbi integer, modulo \( 2^{N} \), where \( N \)
is the width of the target type.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y: i32 = x.wrapping_to_i32();
let z: i16 = x.wrapping_to_i16();
assert_eq!(y, i32::MIN);
assert_eq!(z, i32::MIN as i16);
assert_eq!(i16::from(&x), i32::MIN as i16);Sourcepub fn checked_to_usize(&self) -> Option<usize>
pub fn checked_to_usize(&self) -> Option<usize>
Convert this Arbi integer to a primitive integer type value.
§Return
Some(value) if the Arbi value fits within the target type’s range,
None otherwise.
§Examples
use arbi::Arbi;
let x = Arbi::from(i32::MIN);
let y = x.checked_to_i32();
assert_eq!(y, Some(i32::MIN));
let z = x.checked_to_i16();
assert!(z.is_none());Sourcepub fn fits_usize(&self) -> bool
pub fn fits_usize(&self) -> bool
Return true if this integer fits in this primitive integer type,
false otherwise.
§Examples
use arbi::Arbi;
let mut x = Arbi::from(u8::MAX);
assert!(x.fits_u8());
x.incr();
assert!(!x.fits_u8());Source§impl Arbi
impl Arbi
Sourcepub fn to_string_base(&self, base: Base) -> String
pub fn to_string_base(&self, base: Base) -> String
Sourcepub fn to_string_radix(&self, radix: u32) -> String
pub fn to_string_radix(&self, radix: u32) -> String
Equivalent to Arbi::to_string_base(), but panics if the base is
invalid (i.e. not in \( [2, 36] \)).
§Examples
use arbi::{Arbi, Base};
let a = Arbi::from(123456789);
let s = a.to_string_radix(10);
assert_eq!(s, "123456789");Trait Implementations§
Source§impl<'b> Add<&'b Arbi> for &Arbi
impl<'b> Add<&'b Arbi> for &Arbi
Source§impl<'a> Add<&'a Arbi> for Arbi
impl<'a> Add<&'a Arbi> for Arbi
Source§impl Add<Arbi> for &Arbi
impl Add<Arbi> for &Arbi
Implements &self + rhs.
§Examples
use arbi::{Arbi, Digit};
let a = Arbi::from(-123456);
let b = Arbi::from(1234567);
let b_cap = b.capacity();
let c = &a + b; // In this case, no memory allocation (b's memory is
// used.
assert_eq!(c, 1111111);
assert_eq!(c.capacity(), b_cap);
let a = Arbi::from(-(Digit::MAX as i128));
let b = Arbi::from(-1234567);
let b_cap = b.capacity();
let c = &a + b; // In this case, memory allocation may or may not occur,
// depending on b's capacity.
assert!(c.capacity() >= b_cap);§Complexity
\( O(n) \)
Source§impl Add for Arbi
impl Add for Arbi
Source§impl<'a> AddAssign<&'a Arbi> for Arbi
impl<'a> AddAssign<&'a Arbi> for Arbi
Implements self += &rhs.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-1234567);
let b = Arbi::from(-123456);
a += &b;
assert_eq!(a, -1358023);§Complexity
\( O(n) \)
Source§fn add_assign(&mut self, other: &'a Arbi)
fn add_assign(&mut self, other: &'a Arbi)
+= operation. Read moreSource§impl AddAssign<&i128> for Arbi
impl AddAssign<&i128> for Arbi
Source§fn add_assign(&mut self, other: &i128)
fn add_assign(&mut self, other: &i128)
+= operation. Read moreSource§impl AddAssign<&i16> for Arbi
impl AddAssign<&i16> for Arbi
Source§fn add_assign(&mut self, other: &i16)
fn add_assign(&mut self, other: &i16)
+= operation. Read moreSource§impl AddAssign<&i32> for Arbi
impl AddAssign<&i32> for Arbi
Source§fn add_assign(&mut self, other: &i32)
fn add_assign(&mut self, other: &i32)
+= operation. Read moreSource§impl AddAssign<&i64> for Arbi
impl AddAssign<&i64> for Arbi
Source§fn add_assign(&mut self, other: &i64)
fn add_assign(&mut self, other: &i64)
+= operation. Read moreSource§impl AddAssign<&i8> for Arbi
impl AddAssign<&i8> for Arbi
Source§fn add_assign(&mut self, other: &i8)
fn add_assign(&mut self, other: &i8)
+= operation. Read moreSource§impl AddAssign<&isize> for Arbi
impl AddAssign<&isize> for Arbi
Source§fn add_assign(&mut self, other: &isize)
fn add_assign(&mut self, other: &isize)
+= operation. Read moreSource§impl AddAssign<&u128> for Arbi
impl AddAssign<&u128> for Arbi
Source§fn add_assign(&mut self, other: &u128)
fn add_assign(&mut self, other: &u128)
+= operation. Read moreSource§impl AddAssign<&u16> for Arbi
impl AddAssign<&u16> for Arbi
Source§fn add_assign(&mut self, other: &u16)
fn add_assign(&mut self, other: &u16)
+= operation. Read moreSource§impl AddAssign<&u32> for Arbi
impl AddAssign<&u32> for Arbi
Source§fn add_assign(&mut self, other: &u32)
fn add_assign(&mut self, other: &u32)
+= operation. Read moreSource§impl AddAssign<&u64> for Arbi
impl AddAssign<&u64> for Arbi
Source§fn add_assign(&mut self, other: &u64)
fn add_assign(&mut self, other: &u64)
+= operation. Read moreSource§impl AddAssign<&u8> for Arbi
impl AddAssign<&u8> for Arbi
Source§fn add_assign(&mut self, other: &u8)
fn add_assign(&mut self, other: &u8)
+= operation. Read moreSource§impl AddAssign<&usize> for Arbi
impl AddAssign<&usize> for Arbi
Source§fn add_assign(&mut self, other: &usize)
fn add_assign(&mut self, other: &usize)
+= operation. Read moreSource§impl AddAssign<i128> for Arbi
impl AddAssign<i128> for Arbi
Source§fn add_assign(&mut self, other: i128)
fn add_assign(&mut self, other: i128)
+= operation. Read moreSource§impl AddAssign<i16> for Arbi
impl AddAssign<i16> for Arbi
Source§fn add_assign(&mut self, other: i16)
fn add_assign(&mut self, other: i16)
+= operation. Read moreSource§impl AddAssign<i32> for Arbi
impl AddAssign<i32> for Arbi
Source§fn add_assign(&mut self, other: i32)
fn add_assign(&mut self, other: i32)
+= operation. Read moreSource§impl AddAssign<i64> for Arbi
impl AddAssign<i64> for Arbi
Source§fn add_assign(&mut self, other: i64)
fn add_assign(&mut self, other: i64)
+= operation. Read moreSource§impl AddAssign<i8> for Arbi
impl AddAssign<i8> for Arbi
Source§fn add_assign(&mut self, other: i8)
fn add_assign(&mut self, other: i8)
+= operation. Read moreSource§impl AddAssign<isize> for Arbi
impl AddAssign<isize> for Arbi
Source§fn add_assign(&mut self, other: isize)
fn add_assign(&mut self, other: isize)
+= operation. Read moreSource§impl AddAssign<u128> for Arbi
impl AddAssign<u128> for Arbi
Source§fn add_assign(&mut self, other: u128)
fn add_assign(&mut self, other: u128)
+= operation. Read moreSource§impl AddAssign<u16> for Arbi
impl AddAssign<u16> for Arbi
Source§fn add_assign(&mut self, other: u16)
fn add_assign(&mut self, other: u16)
+= operation. Read moreSource§impl AddAssign<u32> for Arbi
impl AddAssign<u32> for Arbi
Source§fn add_assign(&mut self, other: u32)
fn add_assign(&mut self, other: u32)
+= operation. Read moreSource§impl AddAssign<u64> for Arbi
impl AddAssign<u64> for Arbi
Source§fn add_assign(&mut self, other: u64)
fn add_assign(&mut self, other: u64)
+= operation. Read moreSource§impl AddAssign<u8> for Arbi
impl AddAssign<u8> for Arbi
Source§fn add_assign(&mut self, other: u8)
fn add_assign(&mut self, other: u8)
+= operation. Read moreSource§impl AddAssign<usize> for Arbi
impl AddAssign<usize> for Arbi
Source§fn add_assign(&mut self, other: usize)
fn add_assign(&mut self, other: usize)
+= operation. Read moreSource§impl AddAssign for Arbi
impl AddAssign for Arbi
Implements self += rhs.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-1234567);
let b = Arbi::from(-123456);
a += b;
assert_eq!(a, -1358023);§Complexity
\( O(n) \)
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moreSource§impl Assign<&Arbi> for Arbi
impl Assign<&Arbi> for Arbi
Copies the contents of the argument Arbi integer into this Arbi integer.
If this Arbi integer already has enough capacity to represent value,
then no memory allocation occurs.
Source§impl Assign<&f64> for Arbi
impl Assign<&f64> for Arbi
Source§fn assign(&mut self, d: &f64)
fn assign(&mut self, d: &f64)
Assign a floating-point value to an Arbi.
§Panic
Panics when attempting to convert a NaN or infinity.
§Note
In Rust, when casting a primitive float to a primitive integer type,
NaNs are converted to 0 and values with large magnitudes and
infinities are saturated to the maximum and minimum values of the
integer type.
In contrast, this function panics in these scenarios.
Source§impl Assign<f64> for Arbi
impl Assign<f64> for Arbi
Source§fn assign(&mut self, d: f64)
fn assign(&mut self, d: f64)
Assign a floating-point value to an Arbi.
§Panic
Panics when attempting to convert a NaN or infinity.
§Note
In Rust, when casting a primitive float to a primitive integer type,
NaNs are converted to 0 and values with large magnitudes and
infinities are saturated to the maximum and minimum values of the
integer type.
In contrast, this function panics in these scenarios.
Source§impl<'a> BitAnd<&'a Arbi> for &Arbi
impl<'a> BitAnd<&'a Arbi> for &Arbi
Mathematically, given two integers \( x, y \) with coefficients \( x_{i}, y_{i} \) of their binary representation, the result of \( x \; \& \; y \) (bitwise AND) is an integer \( r \) with base-2 coefficients \( r_{i} \) such that \[ r_{i} = 1 \Longleftrightarrow x_{i} = 1 \wedge y_{i} = 1 \]
Source§impl<'a> BitAndAssign<&'a Arbi> for Arbi
impl<'a> BitAndAssign<&'a Arbi> for Arbi
See BitAnd for the mathematical semantics.
Source§fn bitand_assign(&mut self, rhs: &'a Self)
fn bitand_assign(&mut self, rhs: &'a Self)
&= operation. Read moreSource§impl BitAndAssign for Arbi
impl BitAndAssign for Arbi
See BitAnd for the mathematical semantics.
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<'a> BitOr<&'a Arbi> for &Arbi
impl<'a> BitOr<&'a Arbi> for &Arbi
Mathematically, given two integers \( x, y \) with coefficients \( x_{i}, y_{i} \) of their binary representation, the result of \( x \; | \; y \) (bitwise inclusive OR) is an integer \( r \) with base-2 coefficients \( r_{i} \) such that \[ r_{i} = 1 \Longleftrightarrow x_{i} = 1 \lor y_{i} = 1 \]
Source§impl<'a> BitOrAssign<&'a Arbi> for Arbi
impl<'a> BitOrAssign<&'a Arbi> for Arbi
See BitOr for the mathematical semantics.
Source§fn bitor_assign(&mut self, rhs: &'a Self)
fn bitor_assign(&mut self, rhs: &'a Self)
|= operation. Read moreSource§impl BitOrAssign for Arbi
impl BitOrAssign for Arbi
See BitOr for the mathematical semantics.
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<'a> BitXor<&'a Arbi> for &Arbi
impl<'a> BitXor<&'a Arbi> for &Arbi
Mathematically, given two integers \( x, y \) with coefficients \( x_{i}, y_{i} \) of their binary representation, the result of \( x \; ^\wedge \; y \) (bitwise exclusive OR) is an integer \( r \) with base-2 coefficients \( r_{i} \) such that \[ r_{i} = 1 \Longleftrightarrow (x_{i} = 1 \wedge y_{i} = 0) \lor (x_{i} = 0 \wedge y_{i} = 1) \]
Source§impl<'a> BitXorAssign<&'a Arbi> for Arbi
impl<'a> BitXorAssign<&'a Arbi> for Arbi
See BitXor for the mathematical semantics.
Source§fn bitxor_assign(&mut self, rhs: &'a Self)
fn bitxor_assign(&mut self, rhs: &'a Self)
^= operation. Read moreSource§impl BitXorAssign for Arbi
impl BitXorAssign for Arbi
See BitXor for the mathematical semantics.
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl Display for Arbi
impl Display for Arbi
Outputs the base-10 (decimal) representation of an Arbi integer.
§Examples
use arbi::Arbi;
let a = Arbi::from(12345);
assert_eq!(format!("{}", a), "12345");Source§impl<'a> DivAssign<&'a Arbi> for Arbi
impl<'a> DivAssign<&'a Arbi> for Arbi
See the div() method.
Source§fn div_assign(&mut self, rhs: &'a Arbi)
fn div_assign(&mut self, rhs: &'a Arbi)
/= operation. Read moreSource§impl DivAssign<&i128> for Arbi
impl DivAssign<&i128> for Arbi
Source§fn div_assign(&mut self, other: &i128)
fn div_assign(&mut self, other: &i128)
/= operation. Read moreSource§impl DivAssign<&i16> for Arbi
impl DivAssign<&i16> for Arbi
Source§fn div_assign(&mut self, other: &i16)
fn div_assign(&mut self, other: &i16)
/= operation. Read moreSource§impl DivAssign<&i32> for Arbi
impl DivAssign<&i32> for Arbi
Source§fn div_assign(&mut self, other: &i32)
fn div_assign(&mut self, other: &i32)
/= operation. Read moreSource§impl DivAssign<&i64> for Arbi
impl DivAssign<&i64> for Arbi
Source§fn div_assign(&mut self, other: &i64)
fn div_assign(&mut self, other: &i64)
/= operation. Read moreSource§impl DivAssign<&i8> for Arbi
impl DivAssign<&i8> for Arbi
Source§fn div_assign(&mut self, other: &i8)
fn div_assign(&mut self, other: &i8)
/= operation. Read moreSource§impl DivAssign<&isize> for Arbi
impl DivAssign<&isize> for Arbi
Source§fn div_assign(&mut self, other: &isize)
fn div_assign(&mut self, other: &isize)
/= operation. Read moreSource§impl DivAssign<&u128> for Arbi
impl DivAssign<&u128> for Arbi
Source§fn div_assign(&mut self, other: &u128)
fn div_assign(&mut self, other: &u128)
/= operation. Read moreSource§impl DivAssign<&u16> for Arbi
impl DivAssign<&u16> for Arbi
Source§fn div_assign(&mut self, other: &u16)
fn div_assign(&mut self, other: &u16)
/= operation. Read moreSource§impl DivAssign<&u32> for Arbi
impl DivAssign<&u32> for Arbi
Source§fn div_assign(&mut self, other: &u32)
fn div_assign(&mut self, other: &u32)
/= operation. Read moreSource§impl DivAssign<&u64> for Arbi
impl DivAssign<&u64> for Arbi
Source§fn div_assign(&mut self, other: &u64)
fn div_assign(&mut self, other: &u64)
/= operation. Read moreSource§impl DivAssign<&u8> for Arbi
impl DivAssign<&u8> for Arbi
Source§fn div_assign(&mut self, other: &u8)
fn div_assign(&mut self, other: &u8)
/= operation. Read moreSource§impl DivAssign<&usize> for Arbi
impl DivAssign<&usize> for Arbi
Source§fn div_assign(&mut self, other: &usize)
fn div_assign(&mut self, other: &usize)
/= operation. Read moreSource§impl DivAssign<i128> for Arbi
impl DivAssign<i128> for Arbi
Source§fn div_assign(&mut self, other: i128)
fn div_assign(&mut self, other: i128)
/= operation. Read moreSource§impl DivAssign<i16> for Arbi
impl DivAssign<i16> for Arbi
Source§fn div_assign(&mut self, other: i16)
fn div_assign(&mut self, other: i16)
/= operation. Read moreSource§impl DivAssign<i32> for Arbi
impl DivAssign<i32> for Arbi
Source§fn div_assign(&mut self, other: i32)
fn div_assign(&mut self, other: i32)
/= operation. Read moreSource§impl DivAssign<i64> for Arbi
impl DivAssign<i64> for Arbi
Source§fn div_assign(&mut self, other: i64)
fn div_assign(&mut self, other: i64)
/= operation. Read moreSource§impl DivAssign<i8> for Arbi
impl DivAssign<i8> for Arbi
Source§fn div_assign(&mut self, other: i8)
fn div_assign(&mut self, other: i8)
/= operation. Read moreSource§impl DivAssign<isize> for Arbi
impl DivAssign<isize> for Arbi
Source§fn div_assign(&mut self, other: isize)
fn div_assign(&mut self, other: isize)
/= operation. Read moreSource§impl DivAssign<u128> for Arbi
impl DivAssign<u128> for Arbi
Source§fn div_assign(&mut self, other: u128)
fn div_assign(&mut self, other: u128)
/= operation. Read moreSource§impl DivAssign<u16> for Arbi
impl DivAssign<u16> for Arbi
Source§fn div_assign(&mut self, other: u16)
fn div_assign(&mut self, other: u16)
/= operation. Read moreSource§impl DivAssign<u32> for Arbi
impl DivAssign<u32> for Arbi
Source§fn div_assign(&mut self, other: u32)
fn div_assign(&mut self, other: u32)
/= operation. Read moreSource§impl DivAssign<u64> for Arbi
impl DivAssign<u64> for Arbi
Source§fn div_assign(&mut self, other: u64)
fn div_assign(&mut self, other: u64)
/= operation. Read moreSource§impl DivAssign<u8> for Arbi
impl DivAssign<u8> for Arbi
Source§fn div_assign(&mut self, other: u8)
fn div_assign(&mut self, other: u8)
/= operation. Read moreSource§impl DivAssign<usize> for Arbi
impl DivAssign<usize> for Arbi
Source§fn div_assign(&mut self, other: usize)
fn div_assign(&mut self, other: usize)
/= operation. Read moreSource§impl DivAssign for Arbi
impl DivAssign for Arbi
See the div() method.
Source§fn div_assign(&mut self, rhs: Arbi)
fn div_assign(&mut self, rhs: Arbi)
/= operation. Read moreSource§impl From<&Arbi> for i128
impl From<&Arbi> for i128
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for i16
impl From<&Arbi> for i16
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for i32
impl From<&Arbi> for i32
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for i64
impl From<&Arbi> for i64
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for i8
impl From<&Arbi> for i8
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for isize
impl From<&Arbi> for isize
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for u128
impl From<&Arbi> for u128
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for u16
impl From<&Arbi> for u16
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for u32
impl From<&Arbi> for u32
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for u64
impl From<&Arbi> for u64
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for u8
impl From<&Arbi> for u8
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<&Arbi> for usize
impl From<&Arbi> for usize
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let b = u32::from(&a);
assert_eq!(b, 123456789);
let c = u16::from(&a);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for i128
impl From<Arbi> for i128
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for i16
impl From<Arbi> for i16
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for i32
impl From<Arbi> for i32
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for i64
impl From<Arbi> for i64
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for i8
impl From<Arbi> for i8
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for isize
impl From<Arbi> for isize
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for u128
impl From<Arbi> for u128
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for u16
impl From<Arbi> for u16
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for u32
impl From<Arbi> for u32
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for u64
impl From<Arbi> for u64
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for u8
impl From<Arbi> for u8
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<Arbi> for usize
impl From<Arbi> for usize
Equivalent to converting an Arbi integer to this type using its
corresponding wrapping_to_*() method. For example, see
Arbi::wrapping_to_u32().
Please note that From<&Arbi> is also implemented. See, for example,
impl From<&Arbi> for i32.
§Examples
use arbi::Arbi;
let a = Arbi::from(123456789); // 0b111010110111100110100010101
let a_clone = a.clone();
let b = u32::from(a);
assert_eq!(b, 123456789);
let c = u16::from(a_clone);
assert_eq!(c, 52501); // 0b1100110100010101Source§impl From<f64> for Arbi
impl From<f64> for Arbi
Construct an Arbi integer from a floating-point value.
§Panic
Panics when attempting to convert a NaN or infinity.
§Note
In Rust, when casting a primitive float to a primitive integer type,
NaNs are converted to 0 and values with large magnitudes and infinities
are saturated to the maximum and minimum values of the integer type.
In contrast, this function panics when NaN or infinity is encountered.
Otherwise, the semantics of this function are consistent with Rust’s built-in behavior for casting floats to integers.
§Examples
use arbi::Arbi;
let a = Arbi::from(12345.6789);
assert_eq!(a, 12345);
assert_eq!(a, 12345.6789 as i32)Attempting to convert infinity panics.
use arbi::Arbi;
let a = Arbi::from(f64::INFINITY);Attempting to convert NaN panics.
use arbi::Arbi;
let b = Arbi::from(f64::NAN);§Complexity
\( O(1) \)
Source§impl From<i128> for Arbi
impl From<i128> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<i16> for Arbi
impl From<i16> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<i32> for Arbi
impl From<i32> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<i64> for Arbi
impl From<i64> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<i8> for Arbi
impl From<i8> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<isize> for Arbi
impl From<isize> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<u128> for Arbi
impl From<u128> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<u16> for Arbi
impl From<u16> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<u32> for Arbi
impl From<u32> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<u64> for Arbi
impl From<u64> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<u8> for Arbi
impl From<u8> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl From<usize> for Arbi
impl From<usize> for Arbi
Construct an Arbi integer from this primitive integer type value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u128::MAX);
assert_eq!(a, u128::MAX);
let b = Arbi::from(i128::MIN);
assert_eq!(b, i128::MIN);
// Also works with references
let c = Arbi::from(&i128::MIN);
assert_eq!(c, i128::MIN);§Complexity
\( O(1) \)
Source§impl FromStr for Arbi
impl FromStr for Arbi
Source§fn from_str(src: &str) -> Result<Self, Self::Err>
fn from_str(src: &str) -> Result<Self, Self::Err>
Uses Arbi::from_str_radix() with base 10.
§Examples
use arbi::Arbi;
use core::str::FromStr;
let a = Arbi::from_str("-987654321").unwrap();
assert_eq!(a, -987654321);
let b = "123456789".parse::<Arbi>().unwrap();
assert_eq!(b, 123456789);Source§type Err = ParseError
type Err = ParseError
Source§impl<'b> Mul<&'b Arbi> for &Arbi
impl<'b> Mul<&'b Arbi> for &Arbi
Multiply an Arbi integer by another Arbi integer.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(i16::MIN);
let mut b = a.clone();
a = &a * &b;
assert_eq!(a, (i16::MIN as i128).pow(2));
a = a * &b;
assert_eq!(a, (i16::MIN as i128).pow(3));
a *= &b;
assert_eq!(a, (i16::MIN as i128).pow(4));
a *= b;
assert_eq!(a, (i16::MIN as i128).pow(5));
a = &a * &a;
assert_eq!(
a,
Arbi::from_str_radix("40000000000000000000000000000000000000", 16)
.unwrap()
);§Complexity
\( O(n^{\log_{2}(3)}) \approx O(n^{1.58}) \)
Source§impl MulAssign<&Arbi> for Arbi
impl MulAssign<&Arbi> for Arbi
Source§fn mul_assign(&mut self, rhs: &Arbi)
fn mul_assign(&mut self, rhs: &Arbi)
*= operation. Read moreSource§impl MulAssign<&i128> for Arbi
impl MulAssign<&i128> for Arbi
Source§fn mul_assign(&mut self, other: &i128)
fn mul_assign(&mut self, other: &i128)
*= operation. Read moreSource§impl MulAssign<&i16> for Arbi
impl MulAssign<&i16> for Arbi
Source§fn mul_assign(&mut self, other: &i16)
fn mul_assign(&mut self, other: &i16)
*= operation. Read moreSource§impl MulAssign<&i32> for Arbi
impl MulAssign<&i32> for Arbi
Source§fn mul_assign(&mut self, other: &i32)
fn mul_assign(&mut self, other: &i32)
*= operation. Read moreSource§impl MulAssign<&i64> for Arbi
impl MulAssign<&i64> for Arbi
Source§fn mul_assign(&mut self, other: &i64)
fn mul_assign(&mut self, other: &i64)
*= operation. Read moreSource§impl MulAssign<&i8> for Arbi
impl MulAssign<&i8> for Arbi
Source§fn mul_assign(&mut self, other: &i8)
fn mul_assign(&mut self, other: &i8)
*= operation. Read moreSource§impl MulAssign<&isize> for Arbi
impl MulAssign<&isize> for Arbi
Source§fn mul_assign(&mut self, other: &isize)
fn mul_assign(&mut self, other: &isize)
*= operation. Read moreSource§impl MulAssign<&u128> for Arbi
impl MulAssign<&u128> for Arbi
Source§fn mul_assign(&mut self, other: &u128)
fn mul_assign(&mut self, other: &u128)
*= operation. Read moreSource§impl MulAssign<&u16> for Arbi
impl MulAssign<&u16> for Arbi
Source§fn mul_assign(&mut self, other: &u16)
fn mul_assign(&mut self, other: &u16)
*= operation. Read moreSource§impl MulAssign<&u32> for Arbi
impl MulAssign<&u32> for Arbi
Source§fn mul_assign(&mut self, other: &u32)
fn mul_assign(&mut self, other: &u32)
*= operation. Read moreSource§impl MulAssign<&u64> for Arbi
impl MulAssign<&u64> for Arbi
Source§fn mul_assign(&mut self, other: &u64)
fn mul_assign(&mut self, other: &u64)
*= operation. Read moreSource§impl MulAssign<&u8> for Arbi
impl MulAssign<&u8> for Arbi
Source§fn mul_assign(&mut self, other: &u8)
fn mul_assign(&mut self, other: &u8)
*= operation. Read moreSource§impl MulAssign<&usize> for Arbi
impl MulAssign<&usize> for Arbi
Source§fn mul_assign(&mut self, other: &usize)
fn mul_assign(&mut self, other: &usize)
*= operation. Read moreSource§impl MulAssign<i128> for Arbi
impl MulAssign<i128> for Arbi
Source§fn mul_assign(&mut self, other: i128)
fn mul_assign(&mut self, other: i128)
*= operation. Read moreSource§impl MulAssign<i16> for Arbi
impl MulAssign<i16> for Arbi
Source§fn mul_assign(&mut self, other: i16)
fn mul_assign(&mut self, other: i16)
*= operation. Read moreSource§impl MulAssign<i32> for Arbi
impl MulAssign<i32> for Arbi
Source§fn mul_assign(&mut self, other: i32)
fn mul_assign(&mut self, other: i32)
*= operation. Read moreSource§impl MulAssign<i64> for Arbi
impl MulAssign<i64> for Arbi
Source§fn mul_assign(&mut self, other: i64)
fn mul_assign(&mut self, other: i64)
*= operation. Read moreSource§impl MulAssign<i8> for Arbi
impl MulAssign<i8> for Arbi
Source§fn mul_assign(&mut self, other: i8)
fn mul_assign(&mut self, other: i8)
*= operation. Read moreSource§impl MulAssign<isize> for Arbi
impl MulAssign<isize> for Arbi
Source§fn mul_assign(&mut self, other: isize)
fn mul_assign(&mut self, other: isize)
*= operation. Read moreSource§impl MulAssign<u128> for Arbi
impl MulAssign<u128> for Arbi
Source§fn mul_assign(&mut self, other: u128)
fn mul_assign(&mut self, other: u128)
*= operation. Read moreSource§impl MulAssign<u16> for Arbi
impl MulAssign<u16> for Arbi
Source§fn mul_assign(&mut self, other: u16)
fn mul_assign(&mut self, other: u16)
*= operation. Read moreSource§impl MulAssign<u32> for Arbi
impl MulAssign<u32> for Arbi
Source§fn mul_assign(&mut self, other: u32)
fn mul_assign(&mut self, other: u32)
*= operation. Read moreSource§impl MulAssign<u64> for Arbi
impl MulAssign<u64> for Arbi
Source§fn mul_assign(&mut self, other: u64)
fn mul_assign(&mut self, other: u64)
*= operation. Read moreSource§impl MulAssign<u8> for Arbi
impl MulAssign<u8> for Arbi
Source§fn mul_assign(&mut self, other: u8)
fn mul_assign(&mut self, other: u8)
*= operation. Read moreSource§impl MulAssign<usize> for Arbi
impl MulAssign<usize> for Arbi
Source§fn mul_assign(&mut self, other: usize)
fn mul_assign(&mut self, other: usize)
*= operation. Read moreSource§impl MulAssign for Arbi
impl MulAssign for Arbi
Source§fn mul_assign(&mut self, rhs: Arbi)
fn mul_assign(&mut self, rhs: Arbi)
*= operation. Read moreSource§impl Neg for &Arbi
impl Neg for &Arbi
Source§impl Neg for Arbi
impl Neg for Arbi
Source§impl Not for &Arbi
impl Not for &Arbi
Unary complement operator. Return a new integer representing the ones’ complement of this integer.
Currently, this involves cloning the referenced Arbi integer.
§Example
use arbi::{Arbi, Assign};
let mut a = Arbi::zero();
a = !&a;
assert_eq!(a, -1);
assert_eq!(a, !0);
a.assign(u16::MAX);
a = !&a;
assert_eq!(a, -65536);
assert_eq!(a, !(u16::MAX as i32));§Complexity
\( O(n) \)
Source§impl Not for Arbi
impl Not for Arbi
Unary complement operator. Return the ones’ complement of this integer.
This is done in-place, using the moved-in value.
§Example
use arbi::{Arbi, Assign};
let mut a = Arbi::zero();
a = !a; // in-place
assert_eq!(a, -1);
assert_eq!(a, !0);
a.assign(u16::MAX);
a = !a; // in-place
assert_eq!(a, -65536);
assert_eq!(a, !(u16::MAX as i32));§Complexity
\( O(n) \)
Source§impl Ord for Arbi
impl Ord for Arbi
Source§impl PartialEq<Arbi> for i128
impl PartialEq<Arbi> for i128
Source§impl PartialEq<Arbi> for i16
impl PartialEq<Arbi> for i16
Source§impl PartialEq<Arbi> for i32
impl PartialEq<Arbi> for i32
Source§impl PartialEq<Arbi> for i64
impl PartialEq<Arbi> for i64
Source§impl PartialEq<Arbi> for i8
impl PartialEq<Arbi> for i8
Source§impl PartialEq<Arbi> for isize
impl PartialEq<Arbi> for isize
Source§impl PartialEq<Arbi> for u128
impl PartialEq<Arbi> for u128
Source§impl PartialEq<Arbi> for u16
impl PartialEq<Arbi> for u16
Source§impl PartialEq<Arbi> for u32
impl PartialEq<Arbi> for u32
Source§impl PartialEq<Arbi> for u64
impl PartialEq<Arbi> for u64
Source§impl PartialEq<Arbi> for u8
impl PartialEq<Arbi> for u8
Source§impl PartialEq<Arbi> for usize
impl PartialEq<Arbi> for usize
Source§impl PartialEq<f64> for Arbi
impl PartialEq<f64> for Arbi
Test if this Arbi integer is equal to a floating-point value.
See also PartialOrd<f64> for Arbi for
a description of the semantics of comparing an Arbi to a floating-point
value.
§Examples
use arbi::Arbi;
let a = Arbi::from(f64::MAX);
assert_eq!(a, f64::MAX);
assert_ne!(a, f64::MIN);
// Reverse also implemented
assert_eq!(f64::MAX, a);
assert_ne!(f64::MIN, a);§Complexity
\( O(1) \)
Source§impl PartialEq<i128> for Arbi
impl PartialEq<i128> for Arbi
Source§impl PartialEq<i16> for Arbi
impl PartialEq<i16> for Arbi
Source§impl PartialEq<i32> for Arbi
impl PartialEq<i32> for Arbi
Source§impl PartialEq<i64> for Arbi
impl PartialEq<i64> for Arbi
Source§impl PartialEq<i8> for Arbi
impl PartialEq<i8> for Arbi
Source§impl PartialEq<isize> for Arbi
impl PartialEq<isize> for Arbi
Source§impl PartialEq<u128> for Arbi
impl PartialEq<u128> for Arbi
Source§impl PartialEq<u16> for Arbi
impl PartialEq<u16> for Arbi
Source§impl PartialEq<u32> for Arbi
impl PartialEq<u32> for Arbi
Source§impl PartialEq<u64> for Arbi
impl PartialEq<u64> for Arbi
Source§impl PartialEq<u8> for Arbi
impl PartialEq<u8> for Arbi
Source§impl PartialEq<usize> for Arbi
impl PartialEq<usize> for Arbi
Source§impl PartialOrd<Arbi> for f64
impl PartialOrd<Arbi> for f64
Source§impl PartialOrd<Arbi> for i128
impl PartialOrd<Arbi> for i128
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for i16
impl PartialOrd<Arbi> for i16
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for i32
impl PartialOrd<Arbi> for i32
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for i64
impl PartialOrd<Arbi> for i64
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for i8
impl PartialOrd<Arbi> for i8
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for isize
impl PartialOrd<Arbi> for isize
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for u128
impl PartialOrd<Arbi> for u128
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for u16
impl PartialOrd<Arbi> for u16
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for u32
impl PartialOrd<Arbi> for u32
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for u64
impl PartialOrd<Arbi> for u64
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for u8
impl PartialOrd<Arbi> for u8
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<Arbi> for usize
impl PartialOrd<Arbi> for usize
Compare the value of this primitive integer value to an Arbi integer.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(0 < a);
assert!(u128::MAX > a);
assert!(0 <= a);
assert!(u128::MAX >= a);§Complexity
\( O(1) \)
Source§impl PartialOrd<f64> for &Arbi
impl PartialOrd<f64> for &Arbi
Source§impl PartialOrd<f64> for Arbi
impl PartialOrd<f64> for Arbi
Compare this Arbi integer to a floating-point value.
These comparisons are designed to be consistent with IEEE 754, handling special cases like NaNs and infinities.
NaN:
- Operators
==,<,<=,>, and>=returnfalsewhen comparing with NaN. - Operator
!=returnstruewhen comparing with NaN.
Infinities:
- Positive infinity is treated as greater than any
Arbinumber. - Negative infinity is treated as less than any
Arbinumber.
§Examples
use arbi::Arbi;
let a = Arbi::from(987654321.5);
assert_eq!(a, 987654321.0);
assert!(a >= 987654321.0);
assert!(a <= 987654321.0);
assert!(a > 0.0);
assert!(a < u64::MAX);
// Reverse also implemented
assert!(987654321.0 <= a);
assert!(987654321.0 >= a);
assert!(0.0 < a);
assert!(u64::MAX > a);§Complexity
\( O(1) \)
Source§impl PartialOrd<i128> for &Arbi
impl PartialOrd<i128> for &Arbi
Source§impl PartialOrd<i128> for &mut Arbi
impl PartialOrd<i128> for &mut Arbi
Source§impl PartialOrd<i128> for Arbi
impl PartialOrd<i128> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<i16> for &Arbi
impl PartialOrd<i16> for &Arbi
Source§impl PartialOrd<i16> for &mut Arbi
impl PartialOrd<i16> for &mut Arbi
Source§impl PartialOrd<i16> for Arbi
impl PartialOrd<i16> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<i32> for &Arbi
impl PartialOrd<i32> for &Arbi
Source§impl PartialOrd<i32> for &mut Arbi
impl PartialOrd<i32> for &mut Arbi
Source§impl PartialOrd<i32> for Arbi
impl PartialOrd<i32> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<i64> for &Arbi
impl PartialOrd<i64> for &Arbi
Source§impl PartialOrd<i64> for &mut Arbi
impl PartialOrd<i64> for &mut Arbi
Source§impl PartialOrd<i64> for Arbi
impl PartialOrd<i64> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<i8> for &Arbi
impl PartialOrd<i8> for &Arbi
Source§impl PartialOrd<i8> for &mut Arbi
impl PartialOrd<i8> for &mut Arbi
Source§impl PartialOrd<i8> for Arbi
impl PartialOrd<i8> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<isize> for &Arbi
impl PartialOrd<isize> for &Arbi
Source§impl PartialOrd<isize> for &mut Arbi
impl PartialOrd<isize> for &mut Arbi
Source§impl PartialOrd<isize> for Arbi
impl PartialOrd<isize> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<u128> for &Arbi
impl PartialOrd<u128> for &Arbi
Source§impl PartialOrd<u128> for &mut Arbi
impl PartialOrd<u128> for &mut Arbi
Source§impl PartialOrd<u128> for Arbi
impl PartialOrd<u128> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<u16> for &Arbi
impl PartialOrd<u16> for &Arbi
Source§impl PartialOrd<u16> for &mut Arbi
impl PartialOrd<u16> for &mut Arbi
Source§impl PartialOrd<u16> for Arbi
impl PartialOrd<u16> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<u32> for &Arbi
impl PartialOrd<u32> for &Arbi
Source§impl PartialOrd<u32> for &mut Arbi
impl PartialOrd<u32> for &mut Arbi
Source§impl PartialOrd<u32> for Arbi
impl PartialOrd<u32> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<u64> for &Arbi
impl PartialOrd<u64> for &Arbi
Source§impl PartialOrd<u64> for &mut Arbi
impl PartialOrd<u64> for &mut Arbi
Source§impl PartialOrd<u64> for Arbi
impl PartialOrd<u64> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<u8> for &Arbi
impl PartialOrd<u8> for &Arbi
Source§impl PartialOrd<u8> for &mut Arbi
impl PartialOrd<u8> for &mut Arbi
Source§impl PartialOrd<u8> for Arbi
impl PartialOrd<u8> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd<usize> for &Arbi
impl PartialOrd<usize> for &Arbi
Source§impl PartialOrd<usize> for &mut Arbi
impl PartialOrd<usize> for &mut Arbi
Source§impl PartialOrd<usize> for Arbi
impl PartialOrd<usize> for Arbi
Compare the value of this Arbi integer to a primitive integer value.
This is implemented for all primitive integer types.
§Examples
use arbi::Arbi;
let a = Arbi::from(u64::MAX);
assert!(a > 0);
assert!(a < u128::MAX);
assert!(a >= 0);
assert!(a <= u128::MAX);§Complexity
\( O(1) \)
Source§impl PartialOrd for Arbi
impl PartialOrd for Arbi
Source§impl<'a> RemAssign<&'a Arbi> for Arbi
impl<'a> RemAssign<&'a Arbi> for Arbi
See the div() method.
Source§fn rem_assign(&mut self, rhs: &'a Arbi)
fn rem_assign(&mut self, rhs: &'a Arbi)
%= operation. Read moreSource§impl RemAssign<&i128> for Arbi
impl RemAssign<&i128> for Arbi
Source§fn rem_assign(&mut self, other: &i128)
fn rem_assign(&mut self, other: &i128)
%= operation. Read moreSource§impl RemAssign<&i16> for Arbi
impl RemAssign<&i16> for Arbi
Source§fn rem_assign(&mut self, other: &i16)
fn rem_assign(&mut self, other: &i16)
%= operation. Read moreSource§impl RemAssign<&i32> for Arbi
impl RemAssign<&i32> for Arbi
Source§fn rem_assign(&mut self, other: &i32)
fn rem_assign(&mut self, other: &i32)
%= operation. Read moreSource§impl RemAssign<&i64> for Arbi
impl RemAssign<&i64> for Arbi
Source§fn rem_assign(&mut self, other: &i64)
fn rem_assign(&mut self, other: &i64)
%= operation. Read moreSource§impl RemAssign<&i8> for Arbi
impl RemAssign<&i8> for Arbi
Source§fn rem_assign(&mut self, other: &i8)
fn rem_assign(&mut self, other: &i8)
%= operation. Read moreSource§impl RemAssign<&isize> for Arbi
impl RemAssign<&isize> for Arbi
Source§fn rem_assign(&mut self, other: &isize)
fn rem_assign(&mut self, other: &isize)
%= operation. Read moreSource§impl RemAssign<&u128> for Arbi
impl RemAssign<&u128> for Arbi
Source§fn rem_assign(&mut self, other: &u128)
fn rem_assign(&mut self, other: &u128)
%= operation. Read moreSource§impl RemAssign<&u16> for Arbi
impl RemAssign<&u16> for Arbi
Source§fn rem_assign(&mut self, other: &u16)
fn rem_assign(&mut self, other: &u16)
%= operation. Read moreSource§impl RemAssign<&u32> for Arbi
impl RemAssign<&u32> for Arbi
Source§fn rem_assign(&mut self, other: &u32)
fn rem_assign(&mut self, other: &u32)
%= operation. Read moreSource§impl RemAssign<&u64> for Arbi
impl RemAssign<&u64> for Arbi
Source§fn rem_assign(&mut self, other: &u64)
fn rem_assign(&mut self, other: &u64)
%= operation. Read moreSource§impl RemAssign<&u8> for Arbi
impl RemAssign<&u8> for Arbi
Source§fn rem_assign(&mut self, other: &u8)
fn rem_assign(&mut self, other: &u8)
%= operation. Read moreSource§impl RemAssign<&usize> for Arbi
impl RemAssign<&usize> for Arbi
Source§fn rem_assign(&mut self, other: &usize)
fn rem_assign(&mut self, other: &usize)
%= operation. Read moreSource§impl RemAssign<i128> for Arbi
impl RemAssign<i128> for Arbi
Source§fn rem_assign(&mut self, other: i128)
fn rem_assign(&mut self, other: i128)
%= operation. Read moreSource§impl RemAssign<i16> for Arbi
impl RemAssign<i16> for Arbi
Source§fn rem_assign(&mut self, other: i16)
fn rem_assign(&mut self, other: i16)
%= operation. Read moreSource§impl RemAssign<i32> for Arbi
impl RemAssign<i32> for Arbi
Source§fn rem_assign(&mut self, other: i32)
fn rem_assign(&mut self, other: i32)
%= operation. Read moreSource§impl RemAssign<i64> for Arbi
impl RemAssign<i64> for Arbi
Source§fn rem_assign(&mut self, other: i64)
fn rem_assign(&mut self, other: i64)
%= operation. Read moreSource§impl RemAssign<i8> for Arbi
impl RemAssign<i8> for Arbi
Source§fn rem_assign(&mut self, other: i8)
fn rem_assign(&mut self, other: i8)
%= operation. Read moreSource§impl RemAssign<isize> for Arbi
impl RemAssign<isize> for Arbi
Source§fn rem_assign(&mut self, other: isize)
fn rem_assign(&mut self, other: isize)
%= operation. Read moreSource§impl RemAssign<u128> for Arbi
impl RemAssign<u128> for Arbi
Source§fn rem_assign(&mut self, other: u128)
fn rem_assign(&mut self, other: u128)
%= operation. Read moreSource§impl RemAssign<u16> for Arbi
impl RemAssign<u16> for Arbi
Source§fn rem_assign(&mut self, other: u16)
fn rem_assign(&mut self, other: u16)
%= operation. Read moreSource§impl RemAssign<u32> for Arbi
impl RemAssign<u32> for Arbi
Source§fn rem_assign(&mut self, other: u32)
fn rem_assign(&mut self, other: u32)
%= operation. Read moreSource§impl RemAssign<u64> for Arbi
impl RemAssign<u64> for Arbi
Source§fn rem_assign(&mut self, other: u64)
fn rem_assign(&mut self, other: u64)
%= operation. Read moreSource§impl RemAssign<u8> for Arbi
impl RemAssign<u8> for Arbi
Source§fn rem_assign(&mut self, other: u8)
fn rem_assign(&mut self, other: u8)
%= operation. Read moreSource§impl RemAssign<usize> for Arbi
impl RemAssign<usize> for Arbi
Source§fn rem_assign(&mut self, other: usize)
fn rem_assign(&mut self, other: usize)
%= operation. Read moreSource§impl RemAssign for Arbi
impl RemAssign for Arbi
See the div() method.
Source§fn rem_assign(&mut self, rhs: Arbi)
fn rem_assign(&mut self, rhs: Arbi)
%= operation. Read moreSource§impl Shl<i32> for &Arbi
impl Shl<i32> for &Arbi
Return an Arbi integer representing this integer left-shifted shift bit
positions with vacated bits zero-filled.
Mathematically, the value of the resulting integer is \[ x \times 2^{\text{shift}} \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for left-shifting integers by an unsigned integer value.
The right-hand-side (RHS) of a left shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
- Panics if
rhsis ani32and its value is negative. - Panics if the result of the operation exceeds
Vec’s limits.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::zero() << 1, 0);
assert_eq!(0 << 1, 0);
let mut a = Arbi::neg_one();
a <<= 0;
assert_eq!(a, -1);
assert_eq!(a, -1 << 0);
a <<= 1; // in-place
assert_eq!(a, -2);
assert_eq!(a, -1 << 1);
a = a << 1; // in-place
assert_eq!(a, -4);
assert_eq!(a, -1 << 2);
a = &a << 1; // clones (currently)
assert_eq!(a, -8);
assert_eq!(a, -1 << 3);Negative RHS values cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() << -1;This panics because it would exceed Vec’s limits:
use arbi::Arbi;
let _ = Arbi::one() << Arbi::MAX_BITS;§Complexity
\( O(n) \)
Source§impl Shl<u128> for &Arbi
impl Shl<u128> for &Arbi
Return an Arbi integer representing this integer left-shifted shift bit
positions with vacated bits zero-filled.
Mathematically, the value of the resulting integer is \[ x \times 2^{\text{shift}} \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for left-shifting integers by an unsigned integer value.
The right-hand-side (RHS) of a left shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
- Panics if
rhsis ani32and its value is negative. - Panics if the result of the operation exceeds
Vec’s limits.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::zero() << 1, 0);
assert_eq!(0 << 1, 0);
let mut a = Arbi::neg_one();
a <<= 0;
assert_eq!(a, -1);
assert_eq!(a, -1 << 0);
a <<= 1; // in-place
assert_eq!(a, -2);
assert_eq!(a, -1 << 1);
a = a << 1; // in-place
assert_eq!(a, -4);
assert_eq!(a, -1 << 2);
a = &a << 1; // clones (currently)
assert_eq!(a, -8);
assert_eq!(a, -1 << 3);Negative RHS values cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() << -1;This panics because it would exceed Vec’s limits:
use arbi::Arbi;
let _ = Arbi::one() << Arbi::MAX_BITS;§Complexity
\( O(n) \)
Source§impl Shl<u32> for &Arbi
impl Shl<u32> for &Arbi
Return an Arbi integer representing this integer left-shifted shift bit
positions with vacated bits zero-filled.
Mathematically, the value of the resulting integer is \[ x \times 2^{\text{shift}} \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for left-shifting integers by an unsigned integer value.
The right-hand-side (RHS) of a left shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
- Panics if
rhsis ani32and its value is negative. - Panics if the result of the operation exceeds
Vec’s limits.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::zero() << 1, 0);
assert_eq!(0 << 1, 0);
let mut a = Arbi::neg_one();
a <<= 0;
assert_eq!(a, -1);
assert_eq!(a, -1 << 0);
a <<= 1; // in-place
assert_eq!(a, -2);
assert_eq!(a, -1 << 1);
a = a << 1; // in-place
assert_eq!(a, -4);
assert_eq!(a, -1 << 2);
a = &a << 1; // clones (currently)
assert_eq!(a, -8);
assert_eq!(a, -1 << 3);Negative RHS values cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() << -1;This panics because it would exceed Vec’s limits:
use arbi::Arbi;
let _ = Arbi::one() << Arbi::MAX_BITS;§Complexity
\( O(n) \)
Source§impl Shl<usize> for &Arbi
impl Shl<usize> for &Arbi
Return an Arbi integer representing this integer left-shifted shift bit
positions with vacated bits zero-filled.
Mathematically, the value of the resulting integer is \[ x \times 2^{\text{shift}} \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for left-shifting integers by an unsigned integer value.
The right-hand-side (RHS) of a left shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
- Panics if
rhsis ani32and its value is negative. - Panics if the result of the operation exceeds
Vec’s limits.
§Examples
use arbi::Arbi;
assert_eq!(Arbi::zero() << 1, 0);
assert_eq!(0 << 1, 0);
let mut a = Arbi::neg_one();
a <<= 0;
assert_eq!(a, -1);
assert_eq!(a, -1 << 0);
a <<= 1; // in-place
assert_eq!(a, -2);
assert_eq!(a, -1 << 1);
a = a << 1; // in-place
assert_eq!(a, -4);
assert_eq!(a, -1 << 2);
a = &a << 1; // clones (currently)
assert_eq!(a, -8);
assert_eq!(a, -1 << 3);Negative RHS values cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() << -1;This panics because it would exceed Vec’s limits:
use arbi::Arbi;
let _ = Arbi::one() << Arbi::MAX_BITS;§Complexity
\( O(n) \)
Source§impl<'a> ShlAssign<&'a i32> for Arbi
impl<'a> ShlAssign<&'a i32> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: &'a i32)
fn shl_assign(&mut self, rhs: &'a i32)
<<= operation. Read moreSource§impl<'a> ShlAssign<&'a u128> for Arbi
impl<'a> ShlAssign<&'a u128> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: &'a BitCount)
fn shl_assign(&mut self, rhs: &'a BitCount)
<<= operation. Read moreSource§impl<'a> ShlAssign<&'a u32> for Arbi
impl<'a> ShlAssign<&'a u32> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: &'a u32)
fn shl_assign(&mut self, rhs: &'a u32)
<<= operation. Read moreSource§impl<'a> ShlAssign<&'a usize> for Arbi
impl<'a> ShlAssign<&'a usize> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: &'a usize)
fn shl_assign(&mut self, rhs: &'a usize)
<<= operation. Read moreSource§impl ShlAssign<i32> for Arbi
impl ShlAssign<i32> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: i32)
fn shl_assign(&mut self, rhs: i32)
<<= operation. Read moreSource§impl ShlAssign<u128> for Arbi
impl ShlAssign<u128> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: BitCount)
fn shl_assign(&mut self, rhs: BitCount)
<<= operation. Read moreSource§impl ShlAssign<u32> for Arbi
impl ShlAssign<u32> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<= operation. Read moreSource§impl ShlAssign<usize> for Arbi
impl ShlAssign<usize> for Arbi
See Shl<u128> for &Arbi.
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<= operation. Read moreSource§impl Shr<i32> for &Arbi
impl Shr<i32> for &Arbi
Return a new integer representing this integer right-shifted rhs bit
positions. This is an arithmetic right shift with sign extension.
Mathematically, the value of the resulting integer is \( \frac{x}{2^{\text{shift}}} \), rounded down: \[ \left\lfloor \frac{x}{2^{\text{shift}}} \right\rfloor \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for right shifting primitive integer type values.
The right-hand-side (RHS) of a right shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
Panics if rhs is an i32 and its value is negative.
§Note
Currently, when right-shifting a reference to an Arbi (&Arbi), the
operation involves cloning the Arbi integer, which incurs memory
allocation. To avoid these allocations, prefer using the in-place
right-shift operator >>= on a mutable reference (&mut Arbi), or the
move-based right-shift operator >> on an Arbi instance.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-987654321);
// In-place
a >>= 1;
assert_eq!(a, -493827161);
// Also in-place
a = a >> 1;
assert_eq!(a, -246913581);
// Clones the Arbi integer
a = &a >> 1;
assert_eq!(a, -123456791);Negative shifts cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() >> -1;§Complexity
\( O(n) \)
Source§impl Shr<u128> for &Arbi
impl Shr<u128> for &Arbi
Return a new integer representing this integer right-shifted rhs bit
positions. This is an arithmetic right shift with sign extension.
Mathematically, the value of the resulting integer is \( \frac{x}{2^{\text{shift}}} \), rounded down: \[ \left\lfloor \frac{x}{2^{\text{shift}}} \right\rfloor \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for right shifting primitive integer type values.
The right-hand-side (RHS) of a right shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
Panics if rhs is an i32 and its value is negative.
§Note
Currently, when right-shifting a reference to an Arbi (&Arbi), the
operation involves cloning the Arbi integer, which incurs memory
allocation. To avoid these allocations, prefer using the in-place
right-shift operator >>= on a mutable reference (&mut Arbi), or the
move-based right-shift operator >> on an Arbi instance.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-987654321);
// In-place
a >>= 1;
assert_eq!(a, -493827161);
// Also in-place
a = a >> 1;
assert_eq!(a, -246913581);
// Clones the Arbi integer
a = &a >> 1;
assert_eq!(a, -123456791);Negative shifts cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() >> -1;§Complexity
\( O(n) \)
Source§impl Shr<u32> for &Arbi
impl Shr<u32> for &Arbi
Return a new integer representing this integer right-shifted rhs bit
positions. This is an arithmetic right shift with sign extension.
Mathematically, the value of the resulting integer is \( \frac{x}{2^{\text{shift}}} \), rounded down: \[ \left\lfloor \frac{x}{2^{\text{shift}}} \right\rfloor \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for right shifting primitive integer type values.
The right-hand-side (RHS) of a right shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
Panics if rhs is an i32 and its value is negative.
§Note
Currently, when right-shifting a reference to an Arbi (&Arbi), the
operation involves cloning the Arbi integer, which incurs memory
allocation. To avoid these allocations, prefer using the in-place
right-shift operator >>= on a mutable reference (&mut Arbi), or the
move-based right-shift operator >> on an Arbi instance.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-987654321);
// In-place
a >>= 1;
assert_eq!(a, -493827161);
// Also in-place
a = a >> 1;
assert_eq!(a, -246913581);
// Clones the Arbi integer
a = &a >> 1;
assert_eq!(a, -123456791);Negative shifts cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() >> -1;§Complexity
\( O(n) \)
Source§impl Shr<usize> for &Arbi
impl Shr<usize> for &Arbi
Return a new integer representing this integer right-shifted rhs bit
positions. This is an arithmetic right shift with sign extension.
Mathematically, the value of the resulting integer is \( \frac{x}{2^{\text{shift}}} \), rounded down: \[ \left\lfloor \frac{x}{2^{\text{shift}}} \right\rfloor \] where \( x \) is the big integer.
This is consistent with Rust’s built-in behavior for right shifting primitive integer type values.
The right-hand-side (RHS) of a right shift operation can be a value of type:
BitCountusizeu32i32
While i32 is supported, please note that negative RHS values cause a
panic.
§Panics
Panics if rhs is an i32 and its value is negative.
§Note
Currently, when right-shifting a reference to an Arbi (&Arbi), the
operation involves cloning the Arbi integer, which incurs memory
allocation. To avoid these allocations, prefer using the in-place
right-shift operator >>= on a mutable reference (&mut Arbi), or the
move-based right-shift operator >> on an Arbi instance.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-987654321);
// In-place
a >>= 1;
assert_eq!(a, -493827161);
// Also in-place
a = a >> 1;
assert_eq!(a, -246913581);
// Clones the Arbi integer
a = &a >> 1;
assert_eq!(a, -123456791);Negative shifts cause a panic:
use arbi::Arbi;
let _ = Arbi::zero() >> -1;§Complexity
\( O(n) \)
Source§impl ShrAssign<&i32> for Arbi
impl ShrAssign<&i32> for Arbi
Source§fn shr_assign(&mut self, rhs: &i32)
fn shr_assign(&mut self, rhs: &i32)
>>= operation. Read moreSource§impl ShrAssign<&u128> for Arbi
impl ShrAssign<&u128> for Arbi
Source§fn shr_assign(&mut self, rhs: &BitCount)
fn shr_assign(&mut self, rhs: &BitCount)
>>= operation. Read moreSource§impl ShrAssign<&u32> for Arbi
impl ShrAssign<&u32> for Arbi
Source§fn shr_assign(&mut self, rhs: &u32)
fn shr_assign(&mut self, rhs: &u32)
>>= operation. Read moreSource§impl ShrAssign<&usize> for Arbi
impl ShrAssign<&usize> for Arbi
Source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>= operation. Read moreSource§impl ShrAssign<i32> for Arbi
impl ShrAssign<i32> for Arbi
Source§fn shr_assign(&mut self, rhs: i32)
fn shr_assign(&mut self, rhs: i32)
>>= operation. Read moreSource§impl ShrAssign<u128> for Arbi
impl ShrAssign<u128> for Arbi
Source§fn shr_assign(&mut self, rhs: BitCount)
fn shr_assign(&mut self, rhs: BitCount)
>>= operation. Read moreSource§impl ShrAssign<u32> for Arbi
impl ShrAssign<u32> for Arbi
Source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>= operation. Read moreSource§impl ShrAssign<usize> for Arbi
impl ShrAssign<usize> for Arbi
Source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>= operation. Read moreSource§impl<'b> Sub<&'b Arbi> for &Arbi
impl<'b> Sub<&'b Arbi> for &Arbi
Source§impl<'a> Sub<&'a Arbi> for Arbi
impl<'a> Sub<&'a Arbi> for Arbi
Source§impl Sub<Arbi> for &Arbi
impl Sub<Arbi> for &Arbi
Implements &self - rhs.
§Examples
use arbi::{Arbi, Digit};
let a = Arbi::from(1234567);
let b = Arbi::from(123456);
let b_cap = b.capacity();
let c = &a - b; // In this case, no memory allocation (b's memory is
// used.
assert_eq!(c, 1111111);
assert_eq!(c.capacity(), b_cap);
let a = Arbi::from(-(Digit::MAX as i128));
let b = Arbi::from(-1234567);
let b_cap = b.capacity();
let c = &a - b; // In this case, no memory allocation
assert_eq!(c.capacity(), b_cap);§Complexity
\( O(n) \)
Source§impl Sub for Arbi
impl Sub for Arbi
Source§impl<'a> SubAssign<&'a Arbi> for Arbi
impl<'a> SubAssign<&'a Arbi> for Arbi
Implements self -= &rhs.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-1234567);
let b = Arbi::from(-123456);
a -= &b;
assert_eq!(a, -1111111);§Complexity
\( O(n) \)
Source§fn sub_assign(&mut self, other: &'a Arbi)
fn sub_assign(&mut self, other: &'a Arbi)
-= operation. Read moreSource§impl SubAssign<&i128> for Arbi
impl SubAssign<&i128> for Arbi
Source§fn sub_assign(&mut self, other: &i128)
fn sub_assign(&mut self, other: &i128)
-= operation. Read moreSource§impl SubAssign<&i16> for Arbi
impl SubAssign<&i16> for Arbi
Source§fn sub_assign(&mut self, other: &i16)
fn sub_assign(&mut self, other: &i16)
-= operation. Read moreSource§impl SubAssign<&i32> for Arbi
impl SubAssign<&i32> for Arbi
Source§fn sub_assign(&mut self, other: &i32)
fn sub_assign(&mut self, other: &i32)
-= operation. Read moreSource§impl SubAssign<&i64> for Arbi
impl SubAssign<&i64> for Arbi
Source§fn sub_assign(&mut self, other: &i64)
fn sub_assign(&mut self, other: &i64)
-= operation. Read moreSource§impl SubAssign<&i8> for Arbi
impl SubAssign<&i8> for Arbi
Source§fn sub_assign(&mut self, other: &i8)
fn sub_assign(&mut self, other: &i8)
-= operation. Read moreSource§impl SubAssign<&isize> for Arbi
impl SubAssign<&isize> for Arbi
Source§fn sub_assign(&mut self, other: &isize)
fn sub_assign(&mut self, other: &isize)
-= operation. Read moreSource§impl SubAssign<&u128> for Arbi
impl SubAssign<&u128> for Arbi
Source§fn sub_assign(&mut self, other: &u128)
fn sub_assign(&mut self, other: &u128)
-= operation. Read moreSource§impl SubAssign<&u16> for Arbi
impl SubAssign<&u16> for Arbi
Source§fn sub_assign(&mut self, other: &u16)
fn sub_assign(&mut self, other: &u16)
-= operation. Read moreSource§impl SubAssign<&u32> for Arbi
impl SubAssign<&u32> for Arbi
Source§fn sub_assign(&mut self, other: &u32)
fn sub_assign(&mut self, other: &u32)
-= operation. Read moreSource§impl SubAssign<&u64> for Arbi
impl SubAssign<&u64> for Arbi
Source§fn sub_assign(&mut self, other: &u64)
fn sub_assign(&mut self, other: &u64)
-= operation. Read moreSource§impl SubAssign<&u8> for Arbi
impl SubAssign<&u8> for Arbi
Source§fn sub_assign(&mut self, other: &u8)
fn sub_assign(&mut self, other: &u8)
-= operation. Read moreSource§impl SubAssign<&usize> for Arbi
impl SubAssign<&usize> for Arbi
Source§fn sub_assign(&mut self, other: &usize)
fn sub_assign(&mut self, other: &usize)
-= operation. Read moreSource§impl SubAssign<i128> for Arbi
impl SubAssign<i128> for Arbi
Source§fn sub_assign(&mut self, other: i128)
fn sub_assign(&mut self, other: i128)
-= operation. Read moreSource§impl SubAssign<i16> for Arbi
impl SubAssign<i16> for Arbi
Source§fn sub_assign(&mut self, other: i16)
fn sub_assign(&mut self, other: i16)
-= operation. Read moreSource§impl SubAssign<i32> for Arbi
impl SubAssign<i32> for Arbi
Source§fn sub_assign(&mut self, other: i32)
fn sub_assign(&mut self, other: i32)
-= operation. Read moreSource§impl SubAssign<i64> for Arbi
impl SubAssign<i64> for Arbi
Source§fn sub_assign(&mut self, other: i64)
fn sub_assign(&mut self, other: i64)
-= operation. Read moreSource§impl SubAssign<i8> for Arbi
impl SubAssign<i8> for Arbi
Source§fn sub_assign(&mut self, other: i8)
fn sub_assign(&mut self, other: i8)
-= operation. Read moreSource§impl SubAssign<isize> for Arbi
impl SubAssign<isize> for Arbi
Source§fn sub_assign(&mut self, other: isize)
fn sub_assign(&mut self, other: isize)
-= operation. Read moreSource§impl SubAssign<u128> for Arbi
impl SubAssign<u128> for Arbi
Source§fn sub_assign(&mut self, other: u128)
fn sub_assign(&mut self, other: u128)
-= operation. Read moreSource§impl SubAssign<u16> for Arbi
impl SubAssign<u16> for Arbi
Source§fn sub_assign(&mut self, other: u16)
fn sub_assign(&mut self, other: u16)
-= operation. Read moreSource§impl SubAssign<u32> for Arbi
impl SubAssign<u32> for Arbi
Source§fn sub_assign(&mut self, other: u32)
fn sub_assign(&mut self, other: u32)
-= operation. Read moreSource§impl SubAssign<u64> for Arbi
impl SubAssign<u64> for Arbi
Source§fn sub_assign(&mut self, other: u64)
fn sub_assign(&mut self, other: u64)
-= operation. Read moreSource§impl SubAssign<u8> for Arbi
impl SubAssign<u8> for Arbi
Source§fn sub_assign(&mut self, other: u8)
fn sub_assign(&mut self, other: u8)
-= operation. Read moreSource§impl SubAssign<usize> for Arbi
impl SubAssign<usize> for Arbi
Source§fn sub_assign(&mut self, other: usize)
fn sub_assign(&mut self, other: usize)
-= operation. Read moreSource§impl SubAssign for Arbi
impl SubAssign for Arbi
Implements self -= rhs.
§Examples
use arbi::Arbi;
let mut a = Arbi::from(-1234567);
let b = Arbi::from(-123456);
a -= b;
assert_eq!(a, -1111111);§Complexity
\( O(n) \)
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read more