<p>The nBits field is basically scientific notation in base-256 (256 is 2^8). As an example, we take the one found on the <a href="https://bitcoin.org/en/developer-reference#target-nbits" rel="nofollow noreferrer">Bitcoin.org Developer Reference</a>: <code>0x181bc330</code> (Big-Endian order). This is split into two parts, the <code>0x18</code> exponent (24 in decimal), and the <code>0x1bc330</code> mantissa. The mantissa is 3 bytes long, so subtract 3 from the exponent and then raise 256 to that power, and multiply by the mantissa just as in scientific notation:</p>

<blockquote>
  <p>0x1bc330 × 256 ^ (0x18 - 3)</p>
</blockquote>

<p>Giving the target, the mantissa followed by 21 <code>0x00</code> bytes, or 42 zeroes in hexadecimal. </p>

<p>See this answer for another example: <a href="https://bitcoin.stackexchange.com/a/61967/51948">https://bitcoin.stackexchange.com/a/61967/51948</a></p>

<p>EDIT: You can also think of it as allocating the number of bytes given in the exponent, in this case <code>0x18=24 bytes</code>, and than filling the first 3 bytes with the mantissa.</p>

CC BY-SA 3.0
2017-11-07T09:05:31.837Z
I like the explaination in the edit.
croraf
CC BY-SA 3.0
2017-11-04T12:04:56.643Z
2017-11-07T09:41:56.197Z
2017-11-07T09:41:56.197Z
meshcollider
<p>The result of sha256(s) that miners attempt is a 256 bits long number (64-digits hexadecimal number).</p>

<p>I understand that this 256bits number should be lower than the target threshold, the target threshold being itself a 256 bits long number with a number of leading zeros.</p>

<p>Target threshold is encoded with 4 bytes in the block's headed, as 0xEEMMMMMM in hex notation. EE being the 1byte exponent and MMMMMM being the 3bytes mantissa.</p>

<p>How exactly are these exponent and mantissa translated to the actual 256-bits long target threshold?</p>

<difficulty><block-header>
How is mining difficulty defined (formula)?
croraf
# How is mining difficulty defined (formula)?

(Asked by: username_0 on 2017-11-04)

The result of sha256(s) that miners attempt is a 256 bits long number (64-digits hexadecimal number).

I understand that this 256bits number should be lower than the target threshold, the target threshold being itself a 256 bits long number with a number of leading zeros.

Target threshold is encoded with 4 bytes in the block's headed, as 0xEEMMMMMM in hex notation. EE being the 1byte exponent and MMMMMM being the 3bytes mantissa.

How exactly are these exponent and mantissa translated to the actual 256-bits long target threshold?

**Tags:** difficulty, block-header


---

## 1 answers

### Answer by username_1 on 2017-11-04. Score: 6 | Accepted answer

The nBits field is basically scientific notation in base-256 (256 is 2^8). As an example, we take the one found on the [Bitcoin.org Developer Reference](https://bitcoin.org/en/developer-reference#target-nbits): `0x181bc330` (Big-Endian order). This is split into two parts, the `0x18` exponent (24 in decimal), and the `0x1bc330` mantissa. The mantissa is 3 bytes long, so subtract 3 from the exponent and then raise 256 to that power, and multiply by the mantissa just as in scientific notation:

> 0x1bc330 × 256 ^ (0x18 - 3)

Giving the target, the mantissa followed by 21 `0x00` bytes, or 42 zeroes in hexadecimal.

See this answer for another example: <https://bitcoin.stackexchange.com/a/61967/51948>

EDIT: You can also think of it as allocating the number of bytes given in the exponent, in this case `0x18=24 bytes`, and than filling the first 3 bytes with the mantissa.

> **Comments:**
> **username_0**: I like the explaination in the edit.  

---

