4

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)
elias19r
  • 58
  • 6

1 Answers1

8

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.

Pieter Wuille
  • 105,497
  • 9
  • 194
  • 308