Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

arith_uint256 Class Reference

256-bit unsigned big integer. More...

#include <arith_uint256.h>

+ Inheritance diagram for arith_uint256:
+ Collaboration diagram for arith_uint256:

Public Member Functions

 arith_uint256 ()
 
 arith_uint256 (const base_uint< 256 > &b)
 
 arith_uint256 (uint64_t b)
 
 arith_uint256 (const std::string &str)
 
arith_uint256SetCompact (uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
 The "compact" format is a representation of a whole number N using an unsigned 32bit number similar to a floating point format. More...
 
uint32_t GetCompact (bool fNegative=false) const
 
- Public Member Functions inherited from base_uint< 256 >
 base_uint ()
 
 base_uint (const base_uint &b)
 
 base_uint (uint64_t b)
 
 base_uint (const std::string &str)
 
base_uintoperator= (const base_uint &b)
 
base_uintoperator= (uint64_t b)
 
bool operator! () const
 
const base_uint operator~ () const
 
const base_uint operator- () const
 
double getdouble () const
 
base_uintoperator^= (const base_uint &b)
 
base_uintoperator^= (uint64_t b)
 
base_uintoperator&= (const base_uint &b)
 
base_uintoperator|= (const base_uint &b)
 
base_uintoperator|= (uint64_t b)
 
base_uintoperator<<= (unsigned int shift)
 
base_uintoperator>>= (unsigned int shift)
 
base_uintoperator+= (const base_uint &b)
 
base_uintoperator+= (uint64_t b64)
 
base_uintoperator-= (const base_uint &b)
 
base_uintoperator-= (uint64_t b64)
 
base_uintoperator*= (uint32_t b32)
 
base_uintoperator*= (const base_uint &b)
 
base_uintoperator/= (const base_uint &b)
 
base_uintoperator++ ()
 
const base_uint operator++ (int)
 
base_uintoperator-- ()
 
const base_uint operator-- (int)
 
int CompareTo (const base_uint &b) const
 
bool EqualTo (uint64_t b) const
 
std::string GetHex () const
 
void SetHex (const char *psz)
 
void SetHex (const std::string &str)
 
std::string ToString () const
 
unsigned int size () const
 
unsigned int bits () const
 Returns the position of the highest bit set plus one, or zero if the value is zero. More...
 
uint64_t GetLow64 () const
 

Friends

uint256 ArithToUint256 (const arith_uint256 &)
 
arith_uint256 UintToArith256 (const uint256 &)
 

Additional Inherited Members

- Protected Attributes inherited from base_uint< 256 >
uint32_t pn [WIDTH]
 
- Static Protected Attributes inherited from base_uint< 256 >
static constexpr int WIDTH
 

Detailed Description

256-bit unsigned big integer.

Definition at line 259 of file arith_uint256.h.

Constructor & Destructor Documentation

◆ arith_uint256() [1/4]

arith_uint256::arith_uint256 ( )
inline

Definition at line 261 of file arith_uint256.h.

◆ arith_uint256() [2/4]

arith_uint256::arith_uint256 ( const base_uint< 256 > &  b)
inline

Definition at line 262 of file arith_uint256.h.

◆ arith_uint256() [3/4]

arith_uint256::arith_uint256 ( uint64_t  b)
inline

Definition at line 263 of file arith_uint256.h.

◆ arith_uint256() [4/4]

arith_uint256::arith_uint256 ( const std::string &  str)
inlineexplicit

Definition at line 264 of file arith_uint256.h.

Member Function Documentation

◆ GetCompact()

◆ SetCompact()

arith_uint256 & arith_uint256::SetCompact ( uint32_t  nCompact,
bool *  pfNegative = nullptr,
bool *  pfOverflow = nullptr 
)

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.

Definition at line 206 of file arith_uint256.cpp.

Referenced by CalculateNextWorkRequired(), CheckProofOfWork(), DarkGravityWave(), FindDevNetGenesisBlock(), GetBlockProof(), getblocktemplate(), GetNextWorkRequired(), and KimotoGravityWell().

Friends And Related Function Documentation

◆ ArithToUint256

uint256 ArithToUint256 ( const arith_uint256 )
friend

Definition at line 249 of file arith_uint256.cpp.

◆ UintToArith256

arith_uint256 UintToArith256 ( const uint256 )
friend

Definition at line 256 of file arith_uint256.cpp.


The documentation for this class was generated from the following files:
Released under the MIT license