pub struct Znum { /* private fields */ }Expand description
Tracks which bits “may be 1s” (o) and “may be 0s” (z)
Compared to other bit domains, the Z domain requires minimal storage, which is not scaled with the number of operations, but as a result the accuracy of the domain is somewhat limited.
- “Abstract Domains for Bit-Level Machine Integer and Floating-point Operations”
- Published proceedings entry and DOI: https://doi.org/10.29007/b63g
Implementations§
Source§impl Znum
impl Znum
pub const fn from_parts(ones: u64, zeros: u64) -> Self
Sourcepub const fn from_value(v: u64) -> Self
pub const fn from_value(v: u64) -> Self
From a value, generate a Znum
The resulting Znum only contains the provided value v, and no other values. It is
considered a “constant”
Sourcepub const fn value(&self) -> Option<u64>
pub const fn value(&self) -> Option<u64>
If this is a constant (only a single contained value), return that value. Otherwise, return None.
Sourcepub const fn is_defined(&self) -> bool
pub const fn is_defined(&self) -> bool
Is any value contained in this?
In other words, are there no undefined bits?
Sourcepub const fn contains_value(&self, v: u64) -> bool
pub const fn contains_value(&self, v: u64) -> bool
Is a specific value contained in this?
Sourcepub const fn union(&self, other: Self) -> Self
pub const fn union(&self, other: Self) -> Self
Return the least Z-domain containing every value in either operand.
Sourcepub const fn intersection(&self, other: Self) -> Self
pub const fn intersection(&self, other: Self) -> Self
Return the values represented by both operands.
pub const fn has_value(&self) -> bool
pub const fn max_value(&self) -> Option<u64>
pub const fn min_value(&self) -> Option<u64>
pub const fn unsigned_bounds(&self) -> Option<(u64, u64)>
pub const fn signed_bounds(&self) -> Option<(i64, i64)>
pub const fn bit_or(self, other: Self) -> Self
pub const fn bit_and(self, other: Self) -> Self
pub const fn bit_xor(self, other: Self) -> Self
pub const fn bit_not(self) -> Self
pub const fn add(self, other: Self) -> Self
pub const fn subtract(self, other: Self) -> Self
pub const fn shift_left(self, shift: u8) -> Self
pub const fn shift_right(self, shift: u8) -> Self
pub const fn negate(self) -> Self
pub const fn multiply(self, other: Self) -> Self
Sourcepub const fn checked_div(self, other: Self) -> Option<Self>
pub const fn checked_div(self, other: Self) -> Option<Self>
Divide by other, returning None when it can only be zero.
If other contains both zero and nonzero values, the result describes
the divisions by its nonzero values.