<blockquote>
  <p>When mining, is the truncated target used (the one you get from bits), as opposed to the more accurate target you get by dividing the maxtarget by the difficulty?</p>
</blockquote>

<p>Yes. The bits value actually stored in headers is what matters, as this allows validation of standalone headers without context. Due to headers-first sync this is no longer strictly needed, but there is no reason to change the rules now.</p>

<blockquote>
  <p>Therefore, for all practical purposes, you should truncate the target you get when you divide the maxtarget by the difficulty?</p>
</blockquote>

<p>Yes.</p>

<p>There is at most a 0.0015% difference between the two, though (1 in 2**16).</p>

CC BY-SA 3.0
2017-01-18T20:04:22.733Z
Thanks, as always. So if I were to create my own `bits` from the `targetmax/difficulty` calculation, should I simply use the **first 3 significant bytes** as the coefficient part of the `bits`? If so, should I round up or down?
inersha
CC BY-SA 3.0
2017-01-18T16:04:36.717Z
2017-01-18T16:04:36.717Z
Pieter Wuille
<p>The current value of <code>bits</code> in the block header is: <code>18034379</code>. In <strong>target</strong> form, this is equal to:</p>

<pre><code>0x0000000000000000034379000000000000000000000000000000000000000000
</code></pre>

<p>However, if you calculate the target using the difficulty:</p>

<pre><code>target = maxtarget / difficulty
target = 0x00000000ffff0000000000000000000000000000000000000000000000000000 / 336899932795.8077
target = 0x0000000000000000034379000000004000000000000000000000000000000000
</code></pre>

<p>As you can just about see, this calculated value is more accurate than the  truncated target you get using bits.</p>

<p>My question is:</p>

<ul>
<li>When mining, is the truncated target used (the one you get from <code>bits</code>), as opposed to the more accurate target you get by dividing the maxtarget by the difficulty?</li>
<li>Therefore, for all practical purposes, you should truncate the target you get when you divide the maxtarget by the difficulty?</li>
</ul>

<mining-theory><difficulty>
Is the difficulty target always truncated for practical purposes?
inersha
# Is the difficulty target always truncated for practical purposes?

(Asked by: username_0 on 2017-01-18)

The current value of `bits` in the block header is: `18034379`. In **target** form, this is equal to:

```
0x0000000000000000034379000000000000000000000000000000000000000000

```

However, if you calculate the target using the difficulty:

```
target = maxtarget / difficulty
target = 0x00000000ffff0000000000000000000000000000000000000000000000000000 / 336899932795.8077
target = 0x0000000000000000034379000000004000000000000000000000000000000000

```

As you can just about see, this calculated value is more accurate than the truncated target you get using bits.

My question is:

* When mining, is the truncated target used (the one you get from `bits`), as opposed to the more accurate target you get by dividing the maxtarget by the difficulty?
* Therefore, for all practical purposes, you should truncate the target you get when you divide the maxtarget by the difficulty?

**Tags:** mining-theory, difficulty


---

## 1 answers

### Answer by username_1 on 2017-01-18. Score: 3 | Accepted answer

> When mining, is the truncated target used (the one you get from bits), as opposed to the more accurate target you get by dividing the maxtarget by the difficulty?

Yes. The bits value actually stored in headers is what matters, as this allows validation of standalone headers without context. Due to headers-first sync this is no longer strictly needed, but there is no reason to change the rules now.

> Therefore, for all practical purposes, you should truncate the target you get when you divide the maxtarget by the difficulty?

Yes.

There is at most a 0.0015% difference between the two, though (1 in 2\*\*16).

> **Comments:**
> **username_0**: Thanks, as always. So if I were to create my own `bits` from the `targetmax/difficulty` calculation, should I simply use the **first 3 significant bytes** as the coefficient part of the `bits`? If so, should I round up or down?  

---

