Trait snarkvm_utilities::biginteger::biginteger::BigInteger [−][src]
pub trait BigInteger: ToBytes + FromBytes + Copy + Clone + Debug + Default + Display + Eq + Ord + Send + Sized + Sync + 'static + UniformRand + AsMut<[u64]> + AsRef<[u64]> + From<u64> {}Show methods
fn add_nocarry(&mut self, other: &Self) -> bool; fn sub_noborrow(&mut self, other: &Self) -> bool; fn mul2(&mut self); fn muln(&mut self, amt: u32); fn div2(&mut self); fn divn(&mut self, amt: u32); fn is_odd(&self) -> bool; fn is_even(&self) -> bool; fn is_zero(&self) -> bool; fn num_bits(&self) -> u32; fn get_bit(&self, i: usize) -> bool; fn from_bits_be(bits: Vec<bool>) -> Self; fn to_bits_be(&self) -> Vec<bool>ⓘ; fn find_wnaf(&self) -> Vec<i64>ⓘ; fn to_bits_le(&self) -> Vec<bool>ⓘ { ... } fn write_le<W: Write>(&self, writer: &mut W) -> IoResult<()> { ... } fn read_le<R: Read>(&mut self, reader: &mut R) -> IoResult<()> { ... }
Expand description
TODO (howardwu): Update to use ToBitsLE and ToBitsBE.
This defines a BigInteger
, a smart wrapper around a
sequence of u64
limbs, least-significant digit first.
Required methods
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
Expand description
Add another representation to this one, returning the carry bit.
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
Expand description
Subtract another representation from this one, returning the borrow bit.
fn mul2(&mut self)
[src]
Expand description
Performs a leftwise bitshift of this number, effectively multiplying it by 2. Overflow is ignored.
fn muln(&mut self, amt: u32)
[src]
Expand description
Performs a leftwise bitshift of this number by some amount.
fn div2(&mut self)
[src]
Expand description
Performs a rightwise bitshift of this number, effectively dividing it by 2.
fn divn(&mut self, amt: u32)
[src]
Expand description
Performs a rightwise bitshift of this number by some amount.
fn is_odd(&self) -> bool
[src]
Expand description
Returns true iff this number is odd.
fn is_even(&self) -> bool
[src]
Expand description
Returns true iff this number is even.
fn is_zero(&self) -> bool
[src]
Expand description
Returns true iff this number is zero.
fn num_bits(&self) -> u32
[src]
Expand description
Compute the number of bits needed to encode this number. Always a multiple of 64.
fn get_bit(&self, i: usize) -> bool
[src]
Expand description
Compute the i
-th bit of self
.
fn from_bits_be(bits: Vec<bool>) -> Self
[src]
Expand description
Returns the big integer representation of a given big endian boolean array.
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
Expand description
Returns the bit representation of the big integer in a big endian boolean array, without leading zeros.
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
Expand description
Returns a vector for wnaf.
Provided methods
fn to_bits_le(&self) -> Vec<bool>ⓘ
[src]
Expand description
Returns the bit representation of the big integer in a little endian boolean array, with trailing zeroes.
fn write_le<W: Write>(&self, writer: &mut W) -> IoResult<()>
[src]
Expand description
Writes this BigInteger
as a big endian integer. Always writes
(num_bits
/ 8) bytes.
fn read_le<R: Read>(&mut self, reader: &mut R) -> IoResult<()>
[src]
Expand description
Reads a big endian integer occupying (num_bits
/ 8) bytes into this
representation.
Implementors
impl BigInteger for BigInteger64
[src]
impl BigInteger for BigInteger64
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger128
[src]
impl BigInteger for BigInteger128
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger256
[src]
impl BigInteger for BigInteger256
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger320
[src]
impl BigInteger for BigInteger320
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger384
[src]
impl BigInteger for BigInteger384
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger768
[src]
impl BigInteger for BigInteger768
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.
fn add_nocarry(&mut self, other: &Self) -> bool
[src]
fn sub_noborrow(&mut self, other: &Self) -> bool
[src]
fn mul2(&mut self)
[src]
fn muln(&mut self, n: u32)
[src]
fn div2(&mut self)
[src]
fn divn(&mut self, n: u32)
[src]
fn is_odd(&self) -> bool
[src]
fn is_even(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
fn num_bits(&self) -> u32
[src]
fn get_bit(&self, i: usize) -> bool
[src]
fn to_bits_be(&self) -> Vec<bool>ⓘ
[src]
fn find_wnaf(&self) -> Vec<i64>ⓘ
[src]
impl BigInteger for BigInteger832
[src]
impl BigInteger for BigInteger832
[src]fn from_bits_be(bits: Vec<bool>) -> Self
[src]
fn from_bits_be(bits: Vec<bool>) -> Self
[src]Constructs a BigInteger
by parsing a vector of bits in big endian format
and transforms it into a vector of little endian u64 elements.