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 mathematical integers 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. This works
because we never do arithmetic. We can change the representation in the future (and use arbitrary
precision integers) if this ever becomes a problem, e.g., if we want to do (precise) arithmetic
during constant folding.
Fields§
§sign: Sign§val: u128Implementations§
Source§impl BigInt
impl BigInt
pub const ZERO: BigInt
pub const ONE: BigInt
pub fn is_negative(&self) -> bool
pub fn abs(&self) -> u128
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 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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
Checks if this value is equivalent to the given key. Read more
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read 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>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more