pub struct SignConverter<UPrimitive: UnsignedAddPrimitives, const BIT_LENGTH: usize> {
pub converted_bits: [Col<B1>; BIT_LENGTH],
/* private fields */
}
Expand description
Simple struct to convert to and from Two’s complement representation based on bits. See
SignConverter::new
NOTE: We do not handle witness generation for the converted_bits
and should be handled by
caller
Fields§
§converted_bits: [Col<B1>; BIT_LENGTH]
Implementations§
Source§impl<UPrimitive: UnsignedAddPrimitives, const BIT_LENGTH: usize> SignConverter<UPrimitive, BIT_LENGTH>
impl<UPrimitive: UnsignedAddPrimitives, const BIT_LENGTH: usize> SignConverter<UPrimitive, BIT_LENGTH>
Sourcepub fn new(
table: &mut TableBuilder<'_>,
xin: [Col<B1>; BIT_LENGTH],
conditional: Expr<B1, 1>,
) -> Self
pub fn new( table: &mut TableBuilder<'_>, xin: [Col<B1>; BIT_LENGTH], conditional: Expr<B1, 1>, ) -> Self
Used to conditionally select bit representation based on the MSB (sign bit)
§Parameters
in_bits
: The input bits from MSB to LSBconditional
: The conditional bit to choose input bits, or it’s two’s complement
§Example
- If the conditional is zero, the output will be the input bits.
- If the conditional is one, the output will be the two’s complement of input bits.
pub fn populate<P>(&self, index: &mut TableWitnessSegment<'_, P>) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl<UPrimitive, const BIT_LENGTH: usize> Freeze for SignConverter<UPrimitive, BIT_LENGTH>
impl<UPrimitive, const BIT_LENGTH: usize> RefUnwindSafe for SignConverter<UPrimitive, BIT_LENGTH>where
UPrimitive: RefUnwindSafe,
impl<UPrimitive, const BIT_LENGTH: usize> Send for SignConverter<UPrimitive, BIT_LENGTH>where
UPrimitive: Send,
impl<UPrimitive, const BIT_LENGTH: usize> Sync for SignConverter<UPrimitive, BIT_LENGTH>where
UPrimitive: Sync,
impl<UPrimitive, const BIT_LENGTH: usize> Unpin for SignConverter<UPrimitive, BIT_LENGTH>where
UPrimitive: Unpin,
impl<UPrimitive, const BIT_LENGTH: usize> UnwindSafe for SignConverter<UPrimitive, BIT_LENGTH>where
UPrimitive: UnwindSafe,
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
§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