<p>It looks like the format was designed for other purposes than Bitcoin's target, and used unmodified in the code.</p>

<p>If you want a rationale for why a compact representation in the first place: not to waste space in block headers, presumably. We now know that there is little need for having the target stored in block headers at all (header-first sync does not need it), but before that, it was needed for certain DoS protections.</p>

<p>The particular choice indeed seems a bit odd; the sign bit is certainly unnecessary, and the ranges seem a bit off. However, it's not a terrible choice for a simple generic 32-bit floating point number.</p>

CC BY-SA 3.0
2017-08-04T03:56:19.177Z
2017-08-04T03:56:19.177Z
Pieter Wuille
<p>In Bitcoin, the target is a 256-bit unsigned integer stored using a compact representation similar to a 32-bit floating-point with the following parameters:</p>

<ul>
<li>1 sign bit (is there any use?)</li>
<li>8-bit exponent with offset binary 3 (why?)</li>
<li>base 256 (by using this base, couldn't the exponent be 5-bit long? By definition, the maximum target is set to 2^224 - 1 = 256^28 - 1)</li>
</ul>

<difficulty>
Is there a rationale for the compact representation of the target?
elias19r
# Is there a rationale for the compact representation of the target?

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

In Bitcoin, the target is a 256-bit unsigned integer stored using a compact representation similar to a 32-bit floating-point with the following parameters:

* 1 sign bit (is there any use?)
* 8-bit exponent with offset binary 3 (why?)
* base 256 (by using this base, couldn't the exponent be 5-bit long? By definition, the maximum target is set to 2^224 - 1 = 256^28 - 1)

**Tags:** difficulty


---

## 1 answers

### Answer by username_1 on 2017-08-04. Score: 8 | Accepted answer

It looks like the format was designed for other purposes than Bitcoin's target, and used unmodified in the code.

If you want a rationale for why a compact representation in the first place: not to waste space in block headers, presumably. We now know that there is little need for having the target stored in block headers at all (header-first sync does not need it), but before that, it was needed for certain DoS protections.

The particular choice indeed seems a bit odd; the sign bit is certainly unnecessary, and the ranges seem a bit off. However, it's not a terrible choice for a simple generic 32-bit floating point number.


---

