struct SignedInt<const LIMBS: usize> {
sign: Choice,
magnitude: Uint<LIMBS>,
}Expand description
A Uint which carries a separate sign in order to maintain the same range.
Fields§
§sign: Choice§magnitude: Uint<LIMBS>Implementations§
Source§impl<const LIMBS: usize> SignedInt<LIMBS>
impl<const LIMBS: usize> SignedInt<LIMBS>
pub const ZERO: Self
Sourcepub const fn from_uint_sign(magnitude: Uint<LIMBS>, sign: Choice) -> Self
pub const fn from_uint_sign(magnitude: Uint<LIMBS>, sign: Choice) -> Self
Construct a new SignedInt from a Uint and a sign flag.
Sourcepub const fn magnitude(&self) -> Uint<LIMBS>
pub const fn magnitude(&self) -> Uint<LIMBS>
Obtain the magnitude of the SignedInt, ie. its absolute value.
Sourcepub const fn is_nonzero(&self) -> Choice
pub const fn is_nonzero(&self) -> Choice
Determine if the SignedInt is non-zero.
Sourcepub const fn is_zero_vartime(&self) -> bool
pub const fn is_zero_vartime(&self) -> bool
Determine if the SignedInt is zero in variable time.
Sourcepub const fn is_negative(&self) -> Choice
pub const fn is_negative(&self) -> Choice
Determine if the SignedInt is negative.
Note: -0 is representable in this type, so it may be necessary
to check self.is_nonzero() as well.
Sourcepub const fn lowest(&self) -> i64
pub const fn lowest(&self) -> i64
Extract the lowest 63 bits and convert to its signed representation.
Sourcepub(crate) const fn lincomb_int<const RHS: usize>(
a: &SignedInt<LIMBS>,
b: &SignedInt<LIMBS>,
c: &Int<RHS>,
d: &Int<RHS>,
) -> (Uint<LIMBS>, Uint<RHS>, Choice)
pub(crate) const fn lincomb_int<const RHS: usize>( a: &SignedInt<LIMBS>, b: &SignedInt<LIMBS>, c: &Int<RHS>, d: &Int<RHS>, ) -> (Uint<LIMBS>, Uint<RHS>, Choice)
Compute the linear combination a•b + c•d, returning (lo, hi, sign).
Sourcepub(crate) const fn lincomb_int_reduce_shift<const S: usize>(
a: &Self,
b: &Self,
c: &Int<S>,
d: &Int<S>,
shift: u32,
) -> Self
pub(crate) const fn lincomb_int_reduce_shift<const S: usize>( a: &Self, b: &Self, c: &Int<S>, d: &Int<S>, shift: u32, ) -> Self
Compute the linear combination a•b + c•d, and shift the result
shift bits to the right, returning a signed value in the same range
as the SignedInt inputs.
Sourcepub(crate) const fn lincomb_int_reduce_shift_mod<const S: usize>(
a: &Self,
b: &Self,
c: &Int<S>,
d: &Int<S>,
shift: u32,
m: &Uint<LIMBS>,
mi: Uint<S>,
) -> SignedInt<LIMBS>
pub(crate) const fn lincomb_int_reduce_shift_mod<const S: usize>( a: &Self, b: &Self, c: &Int<S>, d: &Int<S>, shift: u32, m: &Uint<LIMBS>, mi: Uint<S>, ) -> SignedInt<LIMBS>
Compute the linear combination a•b + c•d, and shift the result
shift bits to the right modulo m, returning a signed value in the
same range as the SignedInt inputs.