pub struct JsBigInt {
pub is_positive: bool,
pub limbs: Vec<u64>,
}Expand description
Arbitrary-precision integer adhering to ECMAScript BigInt semantics.
Fields§
§is_positive: boolTrue for non-negative (>= 0), false for negative (< 0).
limbs: Vec<u64>Little-endian base 2^64 limbs. Normalized such that the most significant limb is non-zero, unless the value is zero, where limbs is empty.
Implementations§
Source§impl JsBigInt
impl JsBigInt
Sourcepub fn from_u128(abs: u128, is_positive: bool) -> Self
pub fn from_u128(abs: u128, is_positive: bool) -> Self
Creates a BigInt from an unsigned 128-bit integer and sign.
Sourcepub fn parse(s: &str) -> Result<Self, String>
pub fn parse(s: &str) -> Result<Self, String>
Parses a string into a BigInt, supporting optional sign, base prefixes (0x, 0b, 0o), and optional trailing ‘n’.
Sourcepub fn pow(&self, exp: &Self) -> Result<Self, String>
pub fn pow(&self, exp: &Self) -> Result<Self, String>
Exponentiation (pow) adhering to ECMAScript standard.
Sourcepub fn bit_length(&self) -> usize
pub fn bit_length(&self) -> usize
Bit length (index of highest set bit + 1).
Sourcepub fn to_decimal_string(&self) -> String
pub fn to_decimal_string(&self) -> String
Converts to standard decimal string representation.
Trait Implementations§
impl Eq for JsBigInt
Source§impl Ord for JsBigInt
impl Ord for JsBigInt
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for JsBigInt
impl PartialOrd for JsBigInt
impl StructuralPartialEq for JsBigInt
Auto Trait Implementations§
impl Forget for JsBigInt
impl Freeze for JsBigInt
impl Move for JsBigInt
impl RefUnwindSafe for JsBigInt
impl Send for JsBigInt
impl Sync for JsBigInt
impl Unpin for JsBigInt
impl UnsafeUnpin for JsBigInt
impl UnwindSafe for JsBigInt
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