Struct bitcoin_primitives::ArithU256
source · pub struct ArithU256 { /* private fields */ }Expand description
| 256-bit unsigned big integer. |
Implementations§
source§impl ArithU256
impl ArithU256
sourcepub fn set_compact(
&mut self,
n_compact: u32,
pf_negative: *mut bool,
pf_overflow: *mut bool
) -> &mut ArithU256
pub fn set_compact( &mut self, n_compact: u32, pf_negative: *mut bool, pf_overflow: *mut bool ) -> &mut ArithU256
| This implementation directly uses | shifts instead of going through an intermediate | MPI representation. | | The “compact” format is a representation | of a whole number N using an unsigned | 32bit number similar to a floating point | format. | | The most significant 8 bits are the unsigned | exponent of base 256. | | This exponent can be thought of as “number | of bytes of N”. | | The lower 23 bits are the mantissa. | | Bit number 24 (0x800000) represents | the sign of N. | | N = (-1^sign) * mantissa * 256^(exponent-3) | | Satoshi’s original implementation | used BN_bn2mpi() and BN_mpi2bn(). | | MPI uses the most significant bit of | the first byte as sign. | | Thus 0x1234560000 is compact (0x05123456) | | And 0xc0de000000 is compact (0x0600c0de) | | Bitcoin only uses this “compact” format | for encoding difficulty targets, which | are unsigned 256bit quantities. Thus, | all the complexities of the sign bit | and using base 256 are probably an implementation | accident. |
pub fn get_compact(&self, negative: Option<bool>) -> u32
Trait Implementations§
source§impl DivAssign<&ArithU256> for ArithU256
impl DivAssign<&ArithU256> for ArithU256
source§fn div_assign(&mut self, b: &ArithU256)
fn div_assign(&mut self, b: &ArithU256)
/= operation. Read moresource§impl DivAssign<i64> for ArithU256
impl DivAssign<i64> for ArithU256
source§fn div_assign(&mut self, b64: i64)
fn div_assign(&mut self, b64: i64)
/= operation. Read moresource§impl DivAssign<u32> for ArithU256
impl DivAssign<u32> for ArithU256
source§fn div_assign(&mut self, b32: u32)
fn div_assign(&mut self, b32: u32)
/= operation. Read moresource§impl MulAssign<&ArithU256> for ArithU256
impl MulAssign<&ArithU256> for ArithU256
source§fn mul_assign(&mut self, b: &ArithU256)
fn mul_assign(&mut self, b: &ArithU256)
*= operation. Read moresource§impl MulAssign<i64> for ArithU256
impl MulAssign<i64> for ArithU256
source§fn mul_assign(&mut self, b64: i64)
fn mul_assign(&mut self, b64: i64)
*= operation. Read moresource§impl MulAssign<u32> for ArithU256
impl MulAssign<u32> for ArithU256
source§fn mul_assign(&mut self, b32: u32)
fn mul_assign(&mut self, b32: u32)
*= operation. Read moresource§impl Ord for ArithU256
impl Ord for ArithU256
source§impl PartialEq<ArithU256> for ArithU256
impl PartialEq<ArithU256> for ArithU256
source§impl PartialOrd<ArithU256> for ArithU256
impl PartialOrd<ArithU256> for ArithU256
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Eq for ArithU256
impl Send for ArithU256
impl StructuralEq for ArithU256
impl StructuralPartialEq for ArithU256
impl Sync for ArithU256
Auto Trait Implementations§
Blanket Implementations§
§impl<T, U> CastInto<U> for Twhere
U: CastFrom<T>,
impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.