user7566: I'm trying to calculate the new target for Block 32256, but I'm not getting the expected result. Here's what I did:

Timestamp of the previous block (32255) = 1262152739
Timestamp of block (32255 - 2015 = 30240) = 1261130161
Diff: 1262152739 - 1261130161 = 1022578
Note that there is no limit adjustment (1/2 weeks < 1022578 < 8 weeks)
Current target (0x1d00ffff) = 26959535291011309493156476344723991336010898738574164086137773096960
Multiply the difference with current target
=  1022578 * 26959535291011309493156476344723991336010898738574164086137773096960
= 27568227678811762838892963267635169612395352810293691562874591737943162880
Divide by two weeks
27568227678811762838892963267635169612395352810293691562874591737943162880 / 1209600
= 22791193517536179595645637622052884930882401463536451358196587084939

From what I understand, this should be the new target for block 32256 and the following 2015 blocks. However, it isn't - the correct new target as given in blockexplorer is:
22791060871177364286867400663010583169263383106957897897309909286912
As you can see, my result was kind of in the ballpark, but not correct. What am I missing here?
Related questions:

How is difficulty calculated?
How to calculate new “bits” value?


user208: The actual target (and thus difficulty) is determined by its compact 32-bit encoding.
After the computation you did above, you should round it to the nearest compactly-representable target (24-bit accuracy, multiple of 256). That is the target encoded inside blocks, and the one that matters.

7566: <p>I'm trying to calculate the new target for Block 32256, but I'm not getting the expected result. Here's what I did:</p>

<ol>
<li>Timestamp of <a href="http://blockexplorer.com/block/00000000984f962134a7291e3693075ae03e521f0ee33378ec30a334d860034b" rel="nofollow noreferrer">the previous block (32255)</a> = <code>1262152739</code></li>
<li>Timestamp of <a href="http://blockexplorer.com/block/000000000fa8bfa0f0dd32f956b874b2c7f1772c5fbedcb1b35e03335c7fb0a8" rel="nofollow noreferrer">block (32255 - 2015 = 30240)</a> = <code>1261130161</code></li>
<li>Diff: <code>1262152739 - 1261130161 = 1022578</code></li>
<li>Note that there is no limit adjustment (1/2 weeks &lt; <code>1022578</code> &lt; 8 weeks)</li>
<li>Current target (0x1d00ffff) = <code>26959535291011309493156476344723991336010898738574164086137773096960</code></li>
<li>Multiply the difference with current target<br>
=  <code>1022578 * 26959535291011309493156476344723991336010898738574164086137773096960</code><br>
= <code>27568227678811762838892963267635169612395352810293691562874591737943162880</code></li>
<li>Divide by two weeks<br>
<code>27568227678811762838892963267635169612395352810293691562874591737943162880 / 1209600</code><br>
= <code>22791193517536179595645637622052884930882401463536451358196587084939</code></li>
</ol>

<p>From what I understand, this should be the new target for block 32256 and the following 2015 blocks. However, it isn't - the correct new target as given in blockexplorer is:</p>

<p><code>22791060871177364286867400663010583169263383106957897897309909286912</code></p>

<p>As you can see, my result was kind of in the ballpark, but not correct. What am I missing here?</p>

<p><strong>Related questions:</strong></p>

<ul>
<li><a href="https://bitcoin.stackexchange.com/questions/5838/how-is-difficulty-calculated">How is difficulty calculated?</a></li>
<li><a href="https://bitcoin.stackexchange.com/questions/2924/how-to-calculate-new-bits-value">How to calculate new “bits” value?</a></li>
</ul>
 208: <p>The actual target (and thus difficulty) is determined by its compact 32-bit encoding.</p>

<p>After the computation you did above, you should round it to the nearest compactly-representable target (24-bit accuracy, multiple of 256). That is the target encoded inside blocks, and the one that matters.</p>
