MCPcopy Create free account
hub / github.com/ElementsProject/elements / arith_uint256

Class arith_uint256

src/arith_uint256.h:250–282  ·  view source on GitHub ↗

256-bit unsigned big integer. */

Source from the content-addressed store, hash-verified

248
249/** 256-bit unsigned big integer. */
250class arith_uint256 : public base_uint<256> {
251public:
252 arith_uint256() {}
253 arith_uint256(const base_uint<256>& b) : base_uint<256>(b) {}
254 arith_uint256(uint64_t b) : base_uint<256>(b) {}
255 explicit arith_uint256(const std::string& str) : base_uint<256>(str) {}
256
257 /**
258 * The "compact" format is a representation of a whole
259 * number N using an unsigned 32bit number similar to a
260 * floating point format.
261 * The most significant 8 bits are the unsigned exponent of base 256.
262 * This exponent can be thought of as "number of bytes of N".
263 * The lower 23 bits are the mantissa.
264 * Bit number 24 (0x800000) represents the sign of N.
265 * N = (-1^sign) * mantissa * 256^(exponent-3)
266 *
267 * Satoshi's original implementation used BN_bn2mpi() and BN_mpi2bn().
268 * MPI uses the most significant bit of the first byte as sign.
269 * Thus 0x1234560000 is compact (0x05123456)
270 * and 0xc0de000000 is compact (0x0600c0de)
271 *
272 * Bitcoin only uses this "compact" format for encoding difficulty
273 * targets, which are unsigned 256bit quantities. Thus, all the
274 * complexities of the sign bit and using base 256 are probably an
275 * implementation accident.
276 */
277 arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = nullptr, bool *pfOverflow = nullptr);
278 uint32_t GetCompact(bool fNegative = false) const;
279
280 friend uint256 ArithToUint256(const arith_uint256 &);
281 friend arith_uint256 UintToArith256(const uint256 &);
282};
283
284uint256 ArithToUint256(const arith_uint256 &);
285arith_uint256 UintToArith256(const uint256 &);

Callers 7

BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
getblocktemplateFunction · 0.85

Calls

no outgoing calls

Tested by 5

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68