pub struct BigInt {
sign: Sign,
val: u128,
}
Expand description
A signed integer in the range [-2^128, 2^128], represented by a u128
and an explicit sign.
In the logic, we work with natural numbers so we could represent them with arbitrary precision
integers. We instead take the simpler approach of using a fixed size representation that allows
us to store any Rust literal, i.e., we can represent both i128::MIN
and u128::MAX
. Since we
never do arithmetic, this representation doesn’t present any problems. We may choose to change
the representation in the future (and use arbitrary precision integers) if this ever become a
problem, e.g., if we want to do (precise) arithmetic during constant folding.
Fields§
§sign: Sign
§val: u128
Implementations§
Source§impl BigInt
impl BigInt
pub const ZERO: BigInt = _
pub const ONE: BigInt = _
Sourcepub fn int_min(bit_width: u32) -> BigInt
pub fn int_min(bit_width: u32) -> BigInt
Given the bit width of a signed integer type, produces the minimum integer for that type, i.e., -2^(bit_width - 1).
Trait Implementations§
Source§impl<__D: SpanDecoder> Decodable<__D> for BigInt
impl<__D: SpanDecoder> Decodable<__D> for BigInt
Source§impl FixpointFmt for BigInt
impl FixpointFmt for BigInt
Source§impl Ord for BigInt
impl Ord for BigInt
Source§impl PartialOrd for BigInt
impl PartialOrd for BigInt
impl Copy for BigInt
impl Eq for BigInt
impl StructuralPartialEq for BigInt
Auto Trait Implementations§
impl Freeze for BigInt
impl RefUnwindSafe for BigInt
impl Send for BigInt
impl Sync for BigInt
impl Unpin for BigInt
impl UnwindSafe for BigInt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more