### How to calculate the target from bits

Let's start with a block-header, always 80-bytes that looks like this:

04000000b9e2784a84e5d2468cee60ad14e08d0fee5dda49a37148040000000000000000e9dd2b13157508891880ef68729a1e5ecdde58062ebfa214a89f0141e5a4717faefd2b577627061880564bec

From the 80-bytes, the bits are actually the 72nd to 76th byte:

04000000b9e2784a84e5d2468cee60ad14e08d0fee5dda49a37148040000000000000000e9dd2b13157508891880ef68729a1e5ecdde58062ebfa214a89f0141e5a4717faefd2b57**76270618**80564bec

or

76270618

This number, however, is in little-endian, so we have to reverse the bytes:

18062776

The first byte is the "exponent"

e = 0x18

The next 3 bytes are the "coefficient"

c = 0x062776

You plug this into a formula:

target = c * 2**(8*(e - 3))

In our case, that is:

target = 0x062776 * 2**(8*(0x18 - 3))

Which turns out to...