<p>Target is stored in block header (it's called Bits), and it takes only 4 bytes. We derive target 256-bit value from these 32 bits. That's why it is getting truncated.</p>

<p>There is no need to store all 256 bits, or even 224 bits (if we assume first 4 bytes are zero). We don't need such precision.</p>

<p>You can <a href="https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_stored_in_blocks.3F" rel="nofollow noreferrer">read in wiki</a>, how target is getting calculated from Bits.</p>

<p>You can also check my answer here, with example: 
<a href="https://bitcoin.stackexchange.com/questions/75625/how-does-difficulty-is-defined-for-block-55798/75627#75627">How does difficulty is defined for block &#39;55798&#39;?</a></p>

CC BY-SA 4.0
2018-06-24T12:20:34.693Z
This was really clear, thanks! Just to make sure, setting the trailing bites of the 256-bit version to zero means that when a miner finds a hash with a value which has the correct number of zeros, but it is higher than the target, that hash is invalid?
Paul Razvan Berg
CC BY-SA 4.0
2018-06-24T13:59:25.537Z
@PaulRBerg right, we talk about trailing zeros for simple explanation. In the reality we compare two 256-bit integers
Zergatul
CC BY-SA 4.0
2018-06-24T11:14:29.823Z
2018-06-24T11:14:29.823Z
Zergatul
<p>Reading the docs on <a href="https://en.bitcoin.it/wiki/Target" rel="nofollow noreferrer">target</a>:</p>

<blockquote>
  <p>The maximum target used by SHA256 mining devices is:</p>
  
  <p>0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</p>
  
  <p>Because Bitcoin stores the target as a <strong>floating-point type</strong>, this is truncated:</p>
  
  <p>0x00000000FFFF0000000000000000000000000000000000000000000000000000</p>
</blockquote>

<p>I know that the purpose is to force miners to generate hashes with a value lower than the target. But the docs are vague, why is this truncation required? And then, why truncate after the first four Fs?</p>

<bitcoin-core><hash><difficulty><storage>
Why is the target truncated?
Paul Razvan Berg
# Why is the target truncated?

(Asked by: username_0 on 2018-06-24)

Reading the docs on [target](https://en.bitcoin.it/wiki/Target):

> The maximum target used by SHA256 mining devices is:
>
> 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
>
> Because Bitcoin stores the target as a **floating-point type**, this is truncated:
>
> 0x00000000FFFF0000000000000000000000000000000000000000000000000000

I know that the purpose is to force miners to generate hashes with a value lower than the target. But the docs are vague, why is this truncation required? And then, why truncate after the first four Fs?

**Tags:** bitcoin-core, hash, difficulty, storage


---

## 1 answers

### Answer by username_1 on 2018-06-24. Score: 2 | Accepted answer

Target is stored in block header (it's called Bits), and it takes only 4 bytes. We derive target 256-bit value from these 32 bits. That's why it is getting truncated.

There is no need to store all 256 bits, or even 224 bits (if we assume first 4 bytes are zero). We don't need such precision.

You can [read in wiki](https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_stored_in_blocks.3F), how target is getting calculated from Bits.

You can also check my answer here, with example:
[How does difficulty is defined for block '55798'?](https://bitcoin.stackexchange.com/questions/75625/how-does-difficulty-is-defined-for-block-55798/75627#75627)

> **Comments:**
> **username_0**: This was really clear, thanks! Just to make sure, setting the trailing bites of the 256-bit version to zero means that when a miner finds a hash with a value which has the correct number of zeros, but it is higher than the target, that hash is invalid?  
> **username_1**: @PaulRBerg right, we talk about trailing zeros for simple explanation. In the reality we compare two 256-bit integers  

---

