Bitcoin ABC 0.26.3
P2P Digital Currency
|
256-bit unsigned big integer. More...
#include <arith_uint256.h>
Static Public Member Functions | |
static arith_uint256 | fromDouble (double d) |
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 |
256-bit unsigned big integer.
Definition at line 285 of file arith_uint256.h.
|
inline |
Definition at line 287 of file arith_uint256.h.
|
inline |
Definition at line 288 of file arith_uint256.h.
|
inline |
Definition at line 289 of file arith_uint256.h.
|
inlineexplicit |
Definition at line 290 of file arith_uint256.h.
|
static |
Definition at line 251 of file arith_uint256.cpp.
Definition at line 228 of file arith_uint256.cpp.
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.
|
friend |
Definition at line 261 of file arith_uint256.cpp.
|
friend |
Definition at line 268 of file arith_uint256.cpp.