Bits
The bitcoin block bits field is a 4-byte compact form of the target a block hash must fall below. Learn the exponent and coefficient.
By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.
The bits field is the 4-byte, compact form of the target. The target is the number a block hash must be below for the block to be valid. The full target is 32 bytes long, but storing it in full would waste space in every header. Bits keep just enough of it, in four bytes.
How is the target packed into four bytes?
The four bytes split into two parts:
- The exponent, the first byte. It says how many bytes the coefficient is shifted to the left.
- The coefficient, the next three bytes. It holds the first significant digits of the target.
The value is coefficient × 256^(exponent − 3). The header stores the field in little-endian order, so the exponent is the last byte. Explorers print the four bytes as one number, with the exponent first.
Take block 974,000. Its header stores the bits as ace50117, which reads as 0x1701e5ac:
- The exponent is
0x17, which is 23. - The coefficient is
0x01e5ac. - The coefficient moves 23 − 3 = 20 bytes to the left, and the rest of the 32 bytes are zeros.
The result is 00000000000000000001e5ac0000000000000000000000000000000000000000, a target with 19 zero digits at the front.
How do you turn bits into a target?
Shift the coefficient left by the exponent, as the formula says. This Python function does it:
def bits_to_target(bits: int) -> int:
exponent = bits >> 24
coefficient = bits & 0x007FFFFF # the sign bit (0x00800000) is never set in a valid target
return coefficient * 256 ** (exponent - 3)
print(format(bits_to_target(0x1701E5AC), "064x"))
# 00000000000000000001e5ac0000000000000000000000000000000000000000
Run it on the genesis block's bits, 0x1d00ffff, and you get 00000000ffff followed by zeros. That is the genesis target, and it is the easiest target mainnet allows.
How do you turn a target into bits?
Work in the other direction. Take the three most significant bytes of the target as the coefficient. Count how many bytes sit to their right, and that count plus three is the exponent.
There is one catch. The coefficient's top bit is a sign bit in Bitcoin's number format, so it must stay 0. If the first byte of the coefficient is 0x80 or higher, put a 00 byte in front of it and add one to the exponent. Block 489,888 is an example. Its target starts 000000000000000000eb30, and the first significant byte, eb, is above 7f. So the bits are 1800eb30, not 17eb304f, which would look negative.
Miners do not work this out by hand. Bitcoin Core converts the new target during each difficulty adjustment, and it reads bits back with SetCompact.
What is the target at the start of the chain?
The genesis block uses bits 1d00ffff, which gives a target of 00000000ffff followed by zeros. Difficulty is measured against it. The ratio is called the difficulty, and it is computed as the genesis target divided by the current target.
Block 974,000 has bits 1701e5ac. Its target is about 148 trillion times smaller than the genesis target, which matches its difficulty of about 148.36 trillion. Since the target is so small, a hash has to start with many zeros to pass. Block 974,000's hash starts with 20 zero hex digits.
Why is the target in the header at all?
Nodes could work the target out from the chain. Storing it in the header is redundant, but it makes each header self-describing. Removing the field would need a hard fork, which is not worth the effort, so the field stays.
Why is the field called bits?
The original code never explained the name. It is confusing, because a bit is also the smallest unit of data, and the field has nothing to do with that meaning. It is simply a short, compact encoding of the target.
When does the target change?
The target changes every 2,016 blocks, so the bits in each block change at that point. The target page explains how the new value is calculated from the time the last period took. The timing rules are on the time page.
The bits keep only the top three significant bytes of the target. The hash is checked against that shortened value, not against the longer one the miner calculated. Block 40,320 is an example. Its bits are 1c654657, and the target they store is 0000000065465700 followed by zeros. The precision lost is small compared with the size of the target.
What comes next?
Next is nonce, the last field of the header that miners change.
In this section: Block structure
Something look wrong? Tell us