pub struct BigInt { /* private fields */ }Expand description
An arbitrary-precision signed integer.
Its layout is part of the stable FFI ABI, so a BigInt passes across
languages without conversion. A value that fits i64 is stored inline, and
a wider value uses a heap object of its minimal two’s-complement i64
words, least-significant word first. Results are always in that canonical
form, so equality is word-wise.
Arithmetic is unbounded and signed. / and % truncate toward zero;
floor_div and floor_mod round down.
Bitwise operations sign-extend infinitely, and negative shift counts are errors.
Like the primitive operators, /, %, << and >> panic on those errors;
the try_* methods return them instead, as ffi callbacks need since a panic
cannot unwind across them.
Implementations§
Source§impl BigInt
impl BigInt
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Whether the value is negative.
Sourcepub fn to_i64(&self) -> Option<i64>
pub fn to_i64(&self) -> Option<i64>
Return the value when it fits i64.
See also i64::try_from(&big), which returns an OverflowError instead.
Sourcepub fn to_f64(&self) -> Result<f64>
pub fn to_f64(&self) -> Result<f64>
Convert to the nearest finite double, rounding ties to even.
Raises OverflowError when the value rounds beyond the finite range.
Sourcepub fn try_div(&self, rhs: &BigInt) -> Result<BigInt>
pub fn try_div(&self, rhs: &BigInt) -> Result<BigInt>
Quotient rounded toward zero; raises ZeroDivisionError.
Sourcepub fn try_rem(&self, rhs: &BigInt) -> Result<BigInt>
pub fn try_rem(&self, rhs: &BigInt) -> Result<BigInt>
Remainder of truncating division, zero or with the dividend’s sign.
Sourcepub fn div_rem(&self, rhs: &BigInt) -> Result<(BigInt, BigInt)>
pub fn div_rem(&self, rhs: &BigInt) -> Result<(BigInt, BigInt)>
Truncating quotient and remainder in one pass; raises ZeroDivisionError.
Sourcepub fn floor_div(&self, rhs: &BigInt) -> Result<BigInt>
pub fn floor_div(&self, rhs: &BigInt) -> Result<BigInt>
Quotient rounded toward negative infinity; raises ZeroDivisionError.
Sourcepub fn floor_mod(&self, rhs: &BigInt) -> Result<BigInt>
pub fn floor_mod(&self, rhs: &BigInt) -> Result<BigInt>
Remainder of floor division, zero or with the divisor’s sign.
Trait Implementations§
Source§impl AddAssign for BigInt
impl AddAssign for BigInt
Source§fn add_assign(&mut self, rhs: BigInt)
fn add_assign(&mut self, rhs: BigInt)
+= operation. Read moreSource§impl AddAssign<&BigInt> for BigInt
impl AddAssign<&BigInt> for BigInt
Source§fn add_assign(&mut self, rhs: &BigInt)
fn add_assign(&mut self, rhs: &BigInt)
+= operation. Read moreSource§impl AddAssign<i64> for BigInt
impl AddAssign<i64> for BigInt
Source§fn add_assign(&mut self, rhs: i64)
fn add_assign(&mut self, rhs: i64)
+= operation. Read moreSource§impl AnyCompatible for BigInt
impl AnyCompatible for BigInt
Source§fn type_str() -> String
fn type_str() -> String
int,
ffi.String or Array<int>.Source§unsafe fn is_undefined(field: *const Self) -> bool
unsafe fn is_undefined(field: *const Self) -> bool
field, which holds a value of this type or all-zero bytes,
holds all-zero bytes that are no value of this type, as a null object
reference, a string of type index None or a zero device type: a field
that a creator left undefined for reflection to set. An undefined field
is no value; a nullable reference is Option<T>, whose None is a
defined value. Read moreSource§fn type_schema() -> String
fn type_schema() -> String
Source§unsafe fn copy_to_any_view(this: &Self, data: &mut TVMFFIAny)
unsafe fn copy_to_any_view(this: &Self, data: &mut TVMFFIAny)
Source§unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
Source§unsafe fn check_any_strict(data: &TVMFFIAny) -> bool
unsafe fn check_any_strict(data: &TVMFFIAny) -> bool
Source§unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
Self out of a cell that holds one, retaining any object. Read moreSource§unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
Self out of an owning cell that holds one. Read moreSource§unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
data into a Self by the FFI rules, such as an integer into a
float; Err if it does not convert. Read moreSource§fn get_mismatch_type_info(data: &TVMFFIAny) -> String
fn get_mismatch_type_info(data: &TVMFFIAny) -> String
data in conversion errors; by
default its runtime type key.Source§impl BitAndAssign for BigInt
impl BitAndAssign for BigInt
Source§fn bitand_assign(&mut self, rhs: BigInt)
fn bitand_assign(&mut self, rhs: BigInt)
&= operation. Read moreSource§impl BitAndAssign<&BigInt> for BigInt
impl BitAndAssign<&BigInt> for BigInt
Source§fn bitand_assign(&mut self, rhs: &BigInt)
fn bitand_assign(&mut self, rhs: &BigInt)
&= operation. Read moreSource§impl BitAndAssign<i64> for BigInt
impl BitAndAssign<i64> for BigInt
Source§fn bitand_assign(&mut self, rhs: i64)
fn bitand_assign(&mut self, rhs: i64)
&= operation. Read moreSource§impl BitOrAssign for BigInt
impl BitOrAssign for BigInt
Source§fn bitor_assign(&mut self, rhs: BigInt)
fn bitor_assign(&mut self, rhs: BigInt)
|= operation. Read moreSource§impl BitOrAssign<&BigInt> for BigInt
impl BitOrAssign<&BigInt> for BigInt
Source§fn bitor_assign(&mut self, rhs: &BigInt)
fn bitor_assign(&mut self, rhs: &BigInt)
|= operation. Read moreSource§impl BitOrAssign<i64> for BigInt
impl BitOrAssign<i64> for BigInt
Source§fn bitor_assign(&mut self, rhs: i64)
fn bitor_assign(&mut self, rhs: i64)
|= operation. Read moreSource§impl BitXorAssign for BigInt
impl BitXorAssign for BigInt
Source§fn bitxor_assign(&mut self, rhs: BigInt)
fn bitxor_assign(&mut self, rhs: BigInt)
^= operation. Read moreSource§impl BitXorAssign<&BigInt> for BigInt
impl BitXorAssign<&BigInt> for BigInt
Source§fn bitxor_assign(&mut self, rhs: &BigInt)
fn bitxor_assign(&mut self, rhs: &BigInt)
^= operation. Read moreSource§impl BitXorAssign<i64> for BigInt
impl BitXorAssign<i64> for BigInt
Source§fn bitxor_assign(&mut self, rhs: i64)
fn bitxor_assign(&mut self, rhs: i64)
^= operation. Read moreSource§impl DivAssign for BigInt
impl DivAssign for BigInt
Source§fn div_assign(&mut self, rhs: BigInt)
fn div_assign(&mut self, rhs: BigInt)
/= operation. Read moreSource§impl DivAssign<&BigInt> for BigInt
impl DivAssign<&BigInt> for BigInt
Source§fn div_assign(&mut self, rhs: &BigInt)
fn div_assign(&mut self, rhs: &BigInt)
/= operation. Read moreSource§impl DivAssign<i64> for BigInt
impl DivAssign<i64> for BigInt
Source§fn div_assign(&mut self, rhs: i64)
fn div_assign(&mut self, rhs: i64)
/= operation. Read moreSource§impl DowncastRefFromAny for BigInt
impl DowncastRefFromAny for BigInt
impl Eq for BigInt
Source§impl MulAssign for BigInt
impl MulAssign for BigInt
Source§fn mul_assign(&mut self, rhs: BigInt)
fn mul_assign(&mut self, rhs: BigInt)
*= operation. Read moreSource§impl MulAssign<&BigInt> for BigInt
impl MulAssign<&BigInt> for BigInt
Source§fn mul_assign(&mut self, rhs: &BigInt)
fn mul_assign(&mut self, rhs: &BigInt)
*= operation. Read moreSource§impl MulAssign<i64> for BigInt
impl MulAssign<i64> for BigInt
Source§fn mul_assign(&mut self, rhs: i64)
fn mul_assign(&mut self, rhs: i64)
*= operation. Read moreimpl OptionalCompatible for BigInt
Source§impl Ord for BigInt
impl Ord for BigInt
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PackedCallArg for BigInt
impl PackedCallArg for BigInt
Source§impl<'a> PackedCallArg for &'a BigInt
impl<'a> PackedCallArg for &'a BigInt
Source§impl PartialOrd for BigInt
impl PartialOrd for BigInt
Source§impl RemAssign for BigInt
impl RemAssign for BigInt
Source§fn rem_assign(&mut self, rhs: BigInt)
fn rem_assign(&mut self, rhs: BigInt)
%= operation. Read moreSource§impl RemAssign<&BigInt> for BigInt
impl RemAssign<&BigInt> for BigInt
Source§fn rem_assign(&mut self, rhs: &BigInt)
fn rem_assign(&mut self, rhs: &BigInt)
%= operation. Read moreSource§impl RemAssign<i64> for BigInt
impl RemAssign<i64> for BigInt
Source§fn rem_assign(&mut self, rhs: i64)
fn rem_assign(&mut self, rhs: i64)
%= operation. Read moreimpl Send for BigInt
Source§impl ShlAssign for BigInt
impl ShlAssign for BigInt
Source§fn shl_assign(&mut self, rhs: BigInt)
fn shl_assign(&mut self, rhs: BigInt)
<<= operation. Read moreSource§impl ShlAssign<&BigInt> for BigInt
impl ShlAssign<&BigInt> for BigInt
Source§fn shl_assign(&mut self, rhs: &BigInt)
fn shl_assign(&mut self, rhs: &BigInt)
<<= operation. Read moreSource§impl ShlAssign<i64> for BigInt
impl ShlAssign<i64> for BigInt
Source§fn shl_assign(&mut self, rhs: i64)
fn shl_assign(&mut self, rhs: i64)
<<= operation. Read moreSource§impl ShrAssign for BigInt
impl ShrAssign for BigInt
Source§fn shr_assign(&mut self, rhs: BigInt)
fn shr_assign(&mut self, rhs: BigInt)
>>= operation. Read moreSource§impl ShrAssign<&BigInt> for BigInt
impl ShrAssign<&BigInt> for BigInt
Source§fn shr_assign(&mut self, rhs: &BigInt)
fn shr_assign(&mut self, rhs: &BigInt)
>>= operation. Read moreSource§impl ShrAssign<i64> for BigInt
impl ShrAssign<i64> for BigInt
Source§fn shr_assign(&mut self, rhs: i64)
fn shr_assign(&mut self, rhs: i64)
>>= operation. Read moreSource§impl SubAssign for BigInt
impl SubAssign for BigInt
Source§fn sub_assign(&mut self, rhs: BigInt)
fn sub_assign(&mut self, rhs: BigInt)
-= operation. Read moreSource§impl SubAssign<&BigInt> for BigInt
impl SubAssign<&BigInt> for BigInt
Source§fn sub_assign(&mut self, rhs: &BigInt)
fn sub_assign(&mut self, rhs: &BigInt)
-= operation. Read moreSource§impl SubAssign<i64> for BigInt
impl SubAssign<i64> for BigInt
Source§fn sub_assign(&mut self, rhs: i64)
fn sub_assign(&mut self, rhs: i64)
-= operation. Read more