pub struct ArithU256 { /* private fields */ }
Expand description

| 256-bit unsigned big integer. |

Implementations§

source§

impl ArithU256

source

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. |

source

pub fn get_compact(&self, negative: Option<bool>) -> u32

Trait Implementations§

source§

impl Clone for ArithU256

source§

fn clone(&self) -> ArithU256

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ArithU256

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ArithU256

source§

fn default() -> ArithU256

Returns the “default value” for a type. Read more
source§

impl DivAssign<&ArithU256> for ArithU256

source§

fn div_assign(&mut self, b: &ArithU256)

Performs the /= operation. Read more
source§

impl DivAssign<i64> for ArithU256

source§

fn div_assign(&mut self, b64: i64)

Performs the /= operation. Read more
source§

impl DivAssign<u32> for ArithU256

source§

fn div_assign(&mut self, b32: u32)

Performs the /= operation. Read more
source§

impl From<&BaseUInt<256>> for ArithU256

source§

fn from(b: &BaseUInt<256>) -> Self

Converts to this type from the input type.
source§

impl From<&str> for ArithU256

source§

fn from(str_: &str) -> Self

Converts to this type from the input type.
source§

impl From<u64> for ArithU256

source§

fn from(b: u64) -> Self

Converts to this type from the input type.
source§

impl MulAssign<&ArithU256> for ArithU256

source§

fn mul_assign(&mut self, b: &ArithU256)

Performs the *= operation. Read more
source§

impl MulAssign<i64> for ArithU256

source§

fn mul_assign(&mut self, b64: i64)

Performs the *= operation. Read more
source§

impl MulAssign<u32> for ArithU256

source§

fn mul_assign(&mut self, b32: u32)

Performs the *= operation. Read more
source§

impl Ord for ArithU256

source§

fn cmp(&self, other: &ArithU256) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<ArithU256> for ArithU256

source§

fn eq(&self, other: &ArithU256) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<ArithU256> for ArithU256

source§

fn partial_cmp(&self, other: &ArithU256) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for ArithU256

source§

impl Send for ArithU256

source§

impl StructuralEq for ArithU256

source§

impl StructuralPartialEq for ArithU256

source§

impl Sync for ArithU256

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V