| 292 | } |
| 293 | |
| 294 | uint32_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 | |
| 317 | static void inline HashMix(uint32_t& a, uint32_t& b, uint32_t& c) |
| 318 | { |