pub struct BigInt {
negative: bool,
limbs: Vec<u32>,
}Expand description
ベース 2^32 のリムで表す符号付き任意精度整数。
Fields§
§negative: booltrue なら負。ゼロのときは必ず false(正規形)。
limbs: Vec<u32>絶対値のリム列(リトルエンディアン)。末尾の 0 は持たない(正規形)。
Implementations§
Source§impl BigInt
impl BigInt
Sourcepub fn parse_decimal(s: &str) -> Option<Self>
pub fn parse_decimal(s: &str) -> Option<Self>
十進文字列をパース(先頭に符号可、_ 区切り許容)。失敗で None。
Sourcefn parse_radix(digits: &str, radix: u32) -> Option<Self>
fn parse_radix(digits: &str, radix: u32) -> Option<Self>
指定基数(2〜16)の桁列をパース。
Sourcefn cmp_magnitude(&self, other: &Self) -> Ordering
fn cmp_magnitude(&self, other: &Self) -> Ordering
絶対値の大小比較。
Sourcefn divmod_magnitude(a: &[u32], b: &[u32]) -> (Vec<u32>, Vec<u32>)
fn divmod_magnitude(a: &[u32], b: &[u32]) -> (Vec<u32>, Vec<u32>)
絶対値どうしの除算 → (商, 剰余) を絶対値で返す。 素朴なビット単位の long division(速度より明快さを優先)。
Sourcepub fn to_decimal_string(&self) -> String
pub fn to_decimal_string(&self) -> String
十進文字列化。
Sourcefn bit_length(&self) -> usize
fn bit_length(&self) -> usize
このビット長(絶対値を表すのに必要な最小ビット数)。ゼロは 0。
Sourcefn to_twos_complement(&self, width: usize) -> Vec<u32>
fn to_twos_complement(&self, width: usize) -> Vec<u32>
指定リム数の「2 の補数表現」をリトルエンディアンの u32 列で返す。 負数は ~|x| + 1 を width リム幅で計算する。正数はゼロ拡張。
Sourcefn from_twos_complement(limbs: Vec<u32>) -> Self
fn from_twos_complement(limbs: Vec<u32>) -> Self
width リム幅の 2 の補数表現(リトルエンディアン)から BigInt を復元する。 最上位ビットが 1 なら負数とみなす。
Sourcefn bitop_width(&self, other: &Self) -> usize
fn bitop_width(&self, other: &Self) -> usize
2 つの値のビット演算に必要なリム幅(両者の絶対値ビット長 + 符号ビット余裕)。
Sourcepub fn to_u64_truncated(&self) -> u64
pub fn to_u64_truncated(&self) -> u64
下位64ビットを2の補数のビットパターンとして u64 へ切り詰める。
DataView.prototype.setBigInt64/setBigUint64 がバイト列へ書き戻す際に使う。
Trait Implementations§
impl Eq for BigInt
impl StructuralPartialEq for BigInt
Auto Trait Implementations§
impl Freeze for BigInt
impl RefUnwindSafe for BigInt
impl Send for BigInt
impl Sync for BigInt
impl Unpin for BigInt
impl UnsafeUnpin for BigInt
impl UnwindSafe for BigInt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.