MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetCompact

Method GetCompact

src/uint256.cpp:294–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294uint32_t uint256::GetCompact(bool fNegative) const
295{
296 int nSize = (bits() + 7) / 8;
297 uint32_t nCompact = 0;
298 if (nSize <= 3) {
299 nCompact = GetLow64() << 8 * (3 - nSize);
300 } else {
301 uint256 bn = *this >> 8 * (nSize - 3);
302 nCompact = bn.GetLow64();
303 }
304 // The 0x00800000 bit denotes the sign.
305 // Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
306 if (nCompact & 0x00800000) {
307 nCompact >>= 8;
308 nSize++;
309 }
310 assert((nCompact & ~0x007fffff) == 0);
311 assert(nSize < 256);
312 nCompact |= nSize << 24;
313 nCompact |= (fNegative && (nCompact & 0x007fffff) ? 0x00800000 : 0);
314 return nCompact;
315}
316
317static void inline HashMix(uint32_t& a, uint32_t& b, uint32_t& c)
318{

Callers 5

GetNextWorkRequiredFunction · 0.45
GetStakeWeightMethod · 0.45
GetCoinAgeFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 1

GetLow64Method · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36