<p><code>nBits</code> refers to the <em>target</em>. The target is inversely proportional to the difficulty, and is encoded as a compact representation of a 256-bit number. The first byte of the 32-bit field represents an exponent and the remaining 3 bytes encode a mantissa.</p>
<p><a href="https://i.sstatic.net/apNdW.png" rel="noreferrer"><img src="https://i.sstatic.net/apNdW.png" alt="target explanation in detail" /></a><br />
<sup>Image via <a href="https://btcinformation.org/en/developer-reference#merkle-trees" rel="noreferrer">btcinformation.org</a></sup></p>
<p>E.g. the first (and maximum) target was <code>0x1d00ffff</code>, which is the compact representation of <code>0x00000000ffff0000000000000000000000000000000000000000000000000000</code>, a 256-bit number with the leading 32 bits set to zero, followed by sixteen bits set to one, followed by the remaining bits not defined by the mantissa also being set to zero.</p>
<p>The block hash is usually represented as a hexadecimal number (which include the letters from <code>A–F</code> for the numbers 10-15), but block hashes result from SHA256d hashing and the output of SHA256 is a 256-bit number (hence the name). When miners are searching for a valid block, they create a multitude of block candidates. When one of these candidates' hash digests (interpreted as a 256-bit number) is smaller than or equal than the target, the miner has found a valid block.</p>
<hr />
<p>You can calculate the difficulty from the target with the following formula:</p>
<pre><code>difficulty = max_target / current_target
</code></pre>
<p>where <code>max_target</code> stands for the above mention initial target and corresponds to the minimum difficulty. Alternatively, the formula works out to:</p>
<pre><code>difficulty = 2^208 * 65535 / current_target.
</code></pre>

CC BY-SA 4.0
2017-07-27T15:51:53.300Z
2021-04-21T15:52:44.020Z
2021-04-21T15:52:44.020Z
Murch
<p>When a miner hashes a blocksheader and it produces a hash that is lower than the value represented by <code>nBits</code> then the PoW is considered solved.</p>

<p>What exactly does this mean? For example a SHA256 hash has the following structure: <code>c45bc3de9bff9ee27fc7303a3aa4fa8022ab6608d42bbea4d72bbee9b719703b</code> how do you determine whether this is below an <code>nBits</code> value?</p>

<difficulty>
What does the nBits value represent?
no nein
# What does the nBits value represent?

(Asked by: username_0 on 2017-07-27)

When a miner hashes a blocksheader and it produces a hash that is lower than the value represented by `nBits` then the PoW is considered solved.

What exactly does this mean? For example a SHA256 hash has the following structure: `c45bc3de9bff9ee27fc7303a3aa4fa8022ab6608d42bbea4d72bbee9b719703b` how do you determine whether this is below an `nBits` value?

**Tags:** difficulty


---

## 1 answers

### Answer by username_1 on 2017-07-27. Score: 8 | Accepted answer

`nBits` refers to the *target*. The target is inversely proportional to the difficulty, and is encoded as a compact representation of a 256-bit number. The first byte of the 32-bit field represents an exponent and the remaining 3 bytes encode a mantissa.

[![target explanation in detail](https://i.sstatic.net/apNdW.png)](https://i.sstatic.net/apNdW.png)  
Image via [btcinformation.org](https://btcinformation.org/en/developer-reference#merkle-trees)

E.g. the first (and maximum) target was `0x1d00ffff`, which is the compact representation of `0x00000000ffff0000000000000000000000000000000000000000000000000000`, a 256-bit number with the leading 32 bits set to zero, followed by sixteen bits set to one, followed by the remaining bits not defined by the mantissa also being set to zero.

The block hash is usually represented as a hexadecimal number (which include the letters from `A–F` for the numbers 10-15), but block hashes result from SHA256d hashing and the output of SHA256 is a 256-bit number (hence the name). When miners are searching for a valid block, they create a multitude of block candidates. When one of these candidates' hash digests (interpreted as a 256-bit number) is smaller than or equal than the target, the miner has found a valid block.

---

You can calculate the difficulty from the target with the following formula:

```
difficulty = max_target / current_target

```

where `max_target` stands for the above mention initial target and corresponds to the minimum difficulty. Alternatively, the formula works out to:

```
difficulty = 2^208 * 65535 / current_target.

```


---

