pub struct Signed<const L: u32>(/* private fields */);
Expand description
Signed bitvector.
The number of bits is specified in the generic parameter L.
Signed bitvectors support bitwise operations and wrapping-arithmetic operations.
Arithmetic bit extension is also possible (the sign bit is copied into any bits above it).
Signed bitvectors be converted into Unsigned
or Bitvector
.
Currently, it is not possible to create signed bitvectors directly, only convert into them.
Trait Implementations§
Source§impl<const L: u32> Div for Signed<L>
impl<const L: u32> Div for Signed<L>
Source§impl<const L: u32> Ord for Signed<L>
impl<const L: u32> Ord for Signed<L>
Source§impl<const L: u32> PartialOrd for Signed<L>
impl<const L: u32> PartialOrd for Signed<L>
Source§impl<const L: u32> Shl for Signed<L>
impl<const L: u32> Shl for Signed<L>
Source§fn shl(self, rhs: Signed<L>) -> Self::Output
fn shl(self, rhs: Signed<L>) -> Self::Output
Performs a left shift.
Unlike a right shift, where the behaviour is dependent on signedness, the left shift has the same behaviour: shifted-out bits on the left are discarded and zeros are shifted in on the right.
The right-hand side operand is interpreted as unsigned and if it
is equal or greater to the bit-width, the result is all-zeros,
as in Rust unbounded_shl
. It is planned to restrict the bit-width
in the future so that this edge case can never occur.
Note that this means that shifting left with a negative right operand produces an all-zeros value.
Source§impl<const L: u32> Shr for Signed<L>
impl<const L: u32> Shr for Signed<L>
Source§fn shr(self, rhs: Signed<L>) -> Self::Output
fn shr(self, rhs: Signed<L>) -> Self::Output
Performs an arithmetic right shift.
The right-hand side operand is interpreted as unsigned and if it
is equal or greater to the bit-width, the result is all-zeros or
all-ones depending on the original sign bit, as in Rust unbounded_shr
on signed primitives.
It is planned to restrict the bit-width in the future so that this edge
case can never occur.
Note that this means that shifting right with a negative right operand produces an all-zeros or all-ones value, depending on the original sign bit.
impl<const L: u32> Copy for Signed<L>
impl<const L: u32> Eq for Signed<L>
impl<const L: u32> StructuralPartialEq for Signed<L>
Auto Trait Implementations§
impl<const L: u32> Freeze for Signed<L>
impl<const L: u32> RefUnwindSafe for Signed<L>
impl<const L: u32> Send for Signed<L>
impl<const L: u32> Sync for Signed<L>
impl<const L: u32> Unpin for Signed<L>
impl<const L: u32> UnwindSafe for Signed<L>
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.