<p>The target is a number which the hash of a block header must be less than or equal to in order for that block to be considered valid. This target number, when represented as a 256 bit number, has several leading zeros. The actual number of leading zeros is irrelevant and doesn't matter to anything, but us humans talk about the number of leading zeros as a way to understand what mining is doing with the target. It is easier for people to understand that a hash must have some number of leading zeros which is specified by the target than it is for people to understand that the hash is a very large number, and the target is a very large number, and that the hash must be less than the target. Otherwise, the number of leading zeros is irrelevant. The number of leading zeros is based on the target.</p>

<p>The difficulty is also kind of irrelevant. It is just something for us humans to understand how much work is being done to mine blocks. The difficulty is an alternative representation of the target and is just the highest target value possible divided by the current target value.</p>

<p>Of these three things, only the target actually matters. That is what is used to determine if a hash is valid and that is what is changed every 2016 blocks. The number of leading zeros and the difficulty are just different representations of the target to make it easier for people to understand.</p>

CC BY-SA 3.0
2017-08-06T18:14:08.173Z
Thanks for the answer. Can you please refer me to a source where I can find a simple explanation how to calculate the current target.
user153465
CC BY-SA 3.0
2017-08-06T18:29:15.160Z
AFAIK the only place where the target calculation is actually described is in the source code: https://github.com/bitcoin/bitcoin/blob/1b046603b30ebfab6199a2f92015d507b248b590/src/pow.cpp#L49. The adjustment algorithm is pretty simple: take the previous target, multiply it by the time it took to mine the last difficulty interval, and divide that by the interval between blocks that we want.
Ava Chow
CC BY-SA 3.0
2017-08-07T06:36:31.490Z
Ehh, not the interval between blocks but rather the timespan that we want for the retarget interval, which is 2 weeks.
Ava Chow
CC BY-SA 3.0
2017-08-06T17:58:22.370Z
2017-08-06T17:58:22.370Z
Ava Chow
<p>D = maxTarget/Target</p>

<p>Target is &lt; maxTarget</p>

<p>In words, D divided be maxTarget is the inverse of the probability of a single hash being less than target. Difficulty = 1/probability but scaled down by maxTarget.</p>

<p>It appears maxTarget is used simply to scale D down from the range of billions of septillions (10^33) to the millions.</p>

<p>maxTarget is a 256 bit number (like Target) usually expressed in hex and begins with zeros and can be seen starting like this:  0007FFFF.....  Each of these hex values is a nibble (half a byte) aka 4 bits.  The 7 is a nibble like this: 0111. F = 1111.  So this 0007FFF... number has 3x4+1 = 13 leading zeros when expressed as bits. </p>

<p>HashRate and D are related like this:<br>
D = HR * T / 2^x<br>
where T=target solvetime and x is the leading zeros.</p>

<p>The number of hashes needed for a 50% chance of finding a solution are:<br>
Hashes = D * 2^x = (2^256-1) / target.</p>

<p>There is a pool D and a chain D that are slightly different:<br>
pool_D = coin_D * 2^16 / (2^16 - 1)</p>

<p><a href="https://github.com/zawy12/difficulty-algorithms/issues/12" rel="nofollow noreferrer">https://github.com/zawy12/difficulty-algorithms/issues/12</a></p>

CC BY-SA 4.0
2018-05-13T14:46:06.007Z
2018-05-13T14:46:06.007Z
Scott Roberts
<p>I'm aware of this <a href="https://bitcoin.stackexchange.com/questions/5838/how-is-difficulty-calculated/5840#5840">post</a>, <a href="https://en.bitcoin.it/wiki/Difficulty" rel="nofollow noreferrer">this</a> and this <a href="https://bitcoin.stackexchange.com/questions/8806/what-is-difficulty-and-how-it-relates-to-target">one</a>.</p>

<p>I'm a bit confused with the terms. I don't understand how a number of leading zeros, target and difficulty are related to each other. Also, I don't understand how the number of zero's are calculated for the next target. </p>

<hashpower><difficulty-retargetting>
Proof of work: How are target, difficultly and number of leading zeros related to each other
user153465
# Proof of work: How are target, difficultly and number of leading zeros related to each other

(Asked by: username_0 on 2017-08-06)

I'm aware of this [post](https://bitcoin.stackexchange.com/questions/5838/how-is-difficulty-calculated/5840#5840), [this](https://en.bitcoin.it/wiki/Difficulty) and this [one](https://bitcoin.stackexchange.com/questions/8806/what-is-difficulty-and-how-it-relates-to-target).

I'm a bit confused with the terms. I don't understand how a number of leading zeros, target and difficulty are related to each other. Also, I don't understand how the number of zero's are calculated for the next target.

**Tags:** hashpower, difficulty-retargetting


---

## 2 answers

### Answer by username_1 on 2017-08-06. Score: 2

The target is a number which the hash of a block header must be less than or equal to in order for that block to be considered valid. This target number, when represented as a 256 bit number, has several leading zeros. The actual number of leading zeros is irrelevant and doesn't matter to anything, but us humans talk about the number of leading zeros as a way to understand what mining is doing with the target. It is easier for people to understand that a hash must have some number of leading zeros which is specified by the target than it is for people to understand that the hash is a very large number, and the target is a very large number, and that the hash must be less than the target. Otherwise, the number of leading zeros is irrelevant. The number of leading zeros is based on the target.

The difficulty is also kind of irrelevant. It is just something for us humans to understand how much work is being done to mine blocks. The difficulty is an alternative representation of the target and is just the highest target value possible divided by the current target value.

Of these three things, only the target actually matters. That is what is used to determine if a hash is valid and that is what is changed every 2016 blocks. The number of leading zeros and the difficulty are just different representations of the target to make it easier for people to understand.

> **Comments:**
> **username_0**: Thanks for the answer. Can you please refer me to a source where I can find a simple explanation how to calculate the current target.  
> **username_1**: AFAIK the only place where the target calculation is actually described is in the source code: https://github.com/bitcoin/bitcoin/blob/1b046603b30ebfab6199a2f92015d507b248b590/src/pow.cpp#L49. The adjustment algorithm is pretty simple: take the previous target, multiply it by the time it took to mine the last difficulty interval, and divide that by the interval between blocks that we want.  
> **username_1**: Ehh, not the interval between blocks but rather the timespan that we want for the retarget interval, which is 2 weeks.  

---

### Answer by username_2 on 2018-05-13. Score: 0

D = maxTarget/Target

Target is < maxTarget

In words, D divided be maxTarget is the inverse of the probability of a single hash being less than target. Difficulty = 1/probability but scaled down by maxTarget.

It appears maxTarget is used simply to scale D down from the range of billions of septillions (10^33) to the millions.

maxTarget is a 256 bit number (like Target) usually expressed in hex and begins with zeros and can be seen starting like this: 0007FFFF..... Each of these hex values is a nibble (half a byte) aka 4 bits. The 7 is a nibble like this: 0111. F = 1111. So this 0007FFF... number has 3x4+1 = 13 leading zeros when expressed as bits.

HashRate and D are related like this:  
D = HR \* T / 2^x  
where T=target solvetime and x is the leading zeros.

The number of hashes needed for a 50% chance of finding a solution are:  
Hashes = D \* 2^x = (2^256-1) / target.

There is a pool D and a chain D that are slightly different:  
pool\_D = coin\_D \* 2^16 / (2^16 - 1)

<https://github.com/zawy12/difficulty-algorithms/issues/12>


---

