<p>The first byte, 1D, is the length. The next three bytes are the high bytes of the hash. So we have <code>00ffff</code>, then we add <code>ff</code> bytes onto the end to get to 29 bytes. Then we're done.</p>

<p>We wind up with 3 bytes of leading zeroes because 32-29 is 3. And we get one byte of zeroes from the second byte of the compact bits. So the final result is 00,00,00,00,ff,ff,ff...</p>

CC BY-SA 3.0
2014-04-18T09:02:47.477Z
Thanks for reply. I am still confused. Can your answer how to get "first case" from "static CBigNum bnProofOfWorkLimit(~uint256(0) >> 27);" ?
Vitali Grabovski
CC BY-SA 3.0
2014-04-18T09:16:33.407Z
~0 means all bits set. `>> 32` means to shift the bits left by 32 bits, shifting in zeroes in their place.
David Schwartz
CC BY-SA 3.0
2014-04-18T10:35:47.760Z
Thanks again. Sorry for insistence but can you answer what exactly should I put here "Utils.decodeCompactBits(0x1d00ffffL);" in case "~uint256(0) >> 27" ?
Vitali Grabovski
CC BY-SA 3.0
2014-04-19T20:27:09.963Z
You want 27 zero bits. That's 3 bytes of all zero bits, followed by 3 more zero bits. `00011111` is `1F`. Since the whole thing is 32 bytes, and we need 3 zero bytes, the length of the non-zero segment is 29 bytes, which in hex is 1D. So unless I made a mistake, I get `0x1D1FFFFF`.
David Schwartz
CC BY-SA 3.0
2014-04-18T02:25:39.453Z
2014-04-18T02:25:39.453Z
David Schwartz
<p>Look at the code below from android bitcoin wallet:</p>

<pre><code>proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);
</code></pre>

<p>And look at the code from bitcoin qt wallet:</p>

<pre><code>static CBigNum bnProofOfWorkLimit(~uint256(0) &gt;&gt; 32);
</code></pre>

<p>I assume that in second case ProofOfWorkLimit is 32 "0" and 224 "1" (000000...000111111111....11111111)?</p>

<p>So I don't have an idea how to get first case "0x1d00ffffL" from second case?
In binary "0x1d00ffffL" is 11101000000001111111111111111.</p>

<p>P.S. I have looked in uint256.h. It wasn't helpful.</p>

<bitcoinj><proof-of-work><bitcoin-wallet-app>
What is proofOfWorkLimit?
Vitali Grabovski
# What is proofOfWorkLimit?

(Asked by: username_0 on 2014-04-18)

Look at the code below from android bitcoin wallet:
proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);

And look at the code from bitcoin qt wallet:
static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);

I assume that in second case ProofOfWorkLimit is 32 "0" and 224 "1" (000000...000111111111....11111111)?
So I don't have an idea how to get first case "0x1d00ffffL" from second case?
In binary "0x1d00ffffL" is 11101000000001111111111111111.
P.S. I have looked in uint256.h. It wasn't helpful.

**Tags:** bitcoinj, proof-of-work, bitcoin-wallet-app


---

## 1 answers

### Answer by username_1 on 2014-04-18. Score: 4 | Accepted answer

The first byte, 1D, is the length. The next three bytes are the high bytes of the hash. So we have `00ffff`, then we add `ff` bytes onto the end to get to 29 bytes. Then we're done.

We wind up with 3 bytes of leading zeroes because 32-29 is 3. And we get one byte of zeroes from the second byte of the compact bits. So the final result is 00,00,00,00,ff,ff,ff...

> **Comments:**
> **username_0**: Thanks for reply. I am still confused. Can your answer how to get "first case" from "static CBigNum bnProofOfWorkLimit(~uint256(0) >> 27);" ?  
> **username_1**: ~0 means all bits set. `>> 32` means to shift the bits left by 32 bits, shifting in zeroes in their place.  
> **username_0**: Thanks again. Sorry for insistence but can you answer what exactly should I put here "Utils.decodeCompactBits(0x1d00ffffL);" in case "~uint256(0) >> 27" ?  
> **username_1**: You want 27 zero bits. That's 3 bytes of all zero bits, followed by 3 more zero bits. `00011111` is `1F`. Since the whole thing is 32 bytes, and we need 3 zero bytes, the length of the non-zero segment is 29 bytes, which in hex is 1D. So unless I made a mistake, I get `0x1D1FFFFF`.  

---

