core::num::bigint
이 페이지의 내용
- Structs
Int46absbitbit_lengthbyte_lenbyte_len_unsignedchecked_ilog2checked_isqrtcount_onesdiv_eucliddiv_remfrom_be_bytesfrom_be_bytes_unsignedfrom_i32from_i64from_le_bytesfrom_le_bytes_unsignedfrom_u64gcdilog2is_negativeis_positiveis_power_of_twois_zeroisqrtlcmmodpownext_power_of_twoparse_radixpowrem_euclidset_bitsignumto_be_bytesto_be_bytes_unsignedto_f64to_i32to_i64to_le_bytesto_le_bytes_unsignedto_str_radixto_u64trailing_zeroswrite_be_byteswrite_be_bytes_unsignedwrite_le_byteswrite_le_bytes_unsigned
API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.
int, the arbitrary-precision integer.
#[keyword("int")] routes the type name
here; an unsuffixed literal in an int slot is built by
Int::from_i64 / Int::from_literal.
Structs
IntSource
pub struct IntAn arbitrary-precision integer. Write it int.
The value
n.The value
n.The value
n.
Sourcepub fn parse_radix(§s: str, radix: u32) throws (ParseError) -> Int sin baseradix: an optional sign, then digits of either case. The grammar is the runtime's, the same the primitives'FromStrreads. Panics whenradixis outside 2..=36.The digits in base
radix(2..=36, lowercase),-first when negative.The value as an
i32;nonewhen it does not fit.The value as an
i64;nonewhen it does not fit.The value as a
u64;nonewhen negative or too large.The nearest
f64(ties to even;+/-infpastf64::MAX).truefor 0.truebelow 0.trueabove 0.-1,0or1.The magnitude.
Bits of
|self|without leading zeros (0 for zero; Python'sbit_length).One bits of
|self|(Python'sbit_count): a negative number has infinitely many in two's complement.Zero bits below the lowest one bit, the same for
selfand-self;nonefor zero, which has no one bit.Bit
nofselfin two's complement, sign-extended forever: a negative number has every high bit set.Sets bit
n(asbitreads it) tovalue.self == 2^kfor somek; false for zero and negatives.The smallest power of two
>= self;1forself <= 1.floor(log2(self)); panics unlessself > 0.floor(log2(self));noneunlessself > 0.The shortest two's complement, least significant first: the top bit is the sign (
-1is[255],128is[128, 0]); zero is[0]. Fixed-width integers'to_le_bytesagree in their width.As
to_le_bytes, most significant first.The magnitude, least significant first, with no sign bit (
255is[255]); zero is[0]. Panics on a negative number.As
to_le_bytes_unsigned, most significant first.The length of
to_le_bytes().The length of
to_le_bytes_unsigned(); panics on a negative number.The
intofbytesin two's complement, least significant first (a set top bit is negative). No bytes is zero.As
from_le_bytes, most significant first.The
intof the magnitudebytes, least significant first; never negative. No bytes is zero.As
from_le_bytes_unsigned, most significant first.selfin two's complement in exactlyout.len()bytes, least significant first, sign-extended. Panics if it needs more bytes (byte_len() > out.len()).As
write_le_bytes, most significant first.The magnitude in exactly
out.len()bytes, least significant first, zero-extended. Panics on a negative number or if it needs more bytes (byte_len_unsigned() > out.len()).As
write_le_bytes_unsigned, most significant first.self^exp(square and multiply).self^exp %% m: in0..mform > 0,m + 1..=0form < 0(the sign ofm, as%%). Panics ifmis zero orexpnegative.The greatest common divisor, never negative (
gcd(0, 0) == 0). A runtime kernel (half-gcd reductions, then Lehmer's algorithm) after one division that brings the operands to about the same length.The least common multiple, never negative (
0if either is).The quotient rounded so that
rem_euclidis never negative; panics on zero.The remainder in
0..rhs.abs(); panics on zero.floor(sqrt(self)); panics on a negative number.
floor(sqrt(self)),
nonefor a negative number. Newton steps doubling the precision (the recursion of Python'smath.isqrt): each refines the root of the top2dbits from that of the top2ebits,e = d / 2.(self / rhs, self % rhs)in one division (truncating, like/and%); panics on zero.