Checking an IPv6 prefix that ends inside a hexadecimal group
IPv6 prefixes count bits, while the written address is grouped in sixteen-bit blocks of four hex digits. This guide shows what happens when a prefix ends partway through a group.
Bits versus the groups you read
An IPv6 address has 128 bits, written as eight groups of 16 bits, each shown as up to four hexadecimal digits. A prefix length counts bits from the left. Prefix 48 is three full groups, because 3 × 16 = 48, so the network for 2001:db8:abcd:1234::1 keeps 2001, db8 and abcd and zeroes the rest, giving 2001:db8:abcd::. Prefixes that are multiples of 16 end cleanly at a colon. Most prefixes in daily use, such as /48, /56 and /64, are multiples of 8, and a /52 or /60 puts the boundary inside a group. The text of the address gives no hint of that, so the calculation has to be done on bits.
Prefix 52 keeps one digit of the fourth group
The fourth group of the example is 1234, which is 0001 0010 0011 0100 in binary. A prefix of 52 is 48 plus four bits, so the first four bits of that group are kept and the rest are cleared. Those four bits are 0001, which is the hex digit 1, and the remaining twelve bits become zeros. The group turns into 1000, and the network is 2001:db8:abcd:1000::. Each hexadecimal digit stands for exactly four bits, so prefixes that are multiples of 4 always end between digits. That makes nibble-aligned prefixes easy to read, and a /52 keeps one digit of the group.
Prefixes that cut inside a digit
A prefix that is not a multiple of 4 ends inside a hex digit and keeps only some of its bits. Prefix 50 keeps two bits of the fourth group. The first two bits of 1234 are 00, so everything after them clears and the group becomes 0000, giving 2001:db8:abcd::. Prefix 55 keeps seven bits, 0001001, then pads with zeros to 0001 0010 0000 0000, which is 1200. These cases are why a rule such as drop the digits after the colon works only for some prefixes. The mask must be applied to the binary value, and the result converted back to hex.
More hand-checkable examples
For the same address, prefix 56 keeps the first eight bits of the fourth group, 00010010, which is 12, so the group becomes 1200 and the network is 2001:db8:abcd:1200::. Prefix 60 keeps twelve bits, 0001 0010 0011, which is 123, giving 1230 and the network 2001:db8:abcd:1230::. A shorter prefix works the same way earlier in the address. Prefix 36 is 32 plus four bits, so it keeps the first hex digit of the third group abcd, which is a, and clears the rest: 2001:db8:a000::. Each time, count the full groups, find the leftover bits, keep that many from the next group and zero the rest. Notice that prefixes 55 and 56 give the same network for this address, because the eighth bit of the group 1234 is a zero, so keeping seven or eight bits yields 1200 either way. Different prefixes can therefore share a network string while describing blocks of different sizes, which is why the prefix length must always accompany the network when you record it.
How the calculator computes the network
The calculator parses the address into a 128-bit integer, shifts it right by 128 minus the prefix and shifts it back left by the same amount. The right shift discards the host bits, and the left shift restores the position of the kept bits with zeros below. The block size is 2^(128 - prefix). For prefix 52 that leaves 76 free bits. A /52 contains 2^12 = 4,096 blocks of /64, since 64 - 52 = 12. These relations make it simple to check a result: the network must be a multiple of the block size, and the entered address must lie between the network and the network plus the block size minus one.
Mistakes that arise from reading groups as units
The usual error is truncating text. Someone cuts 2001:db8:abcd:1234::1 after the third colon and calls it a /48, which is correct, then repeats the move for a /52 and gets the wrong answer, because 1234 is not 1000. A second error counts hex digits instead of bits, so that a prefix of 12 is read as twelve digits. A third reads a prefix of 52 as three groups plus 4 digits, instead of three groups plus 4 bits. Each case is avoided by remembering that one hex digit is four bits and one group is sixteen.
Why aligned prefixes are common in planning
Operators often choose prefixes at nibble boundaries such as /48, /52, /56 or /60 because the resulting boundaries are visible in the text, which helps people read and document a plan. For instance, a /56 gives 256 subnets of /64 whose fourth group runs from 0000 to 00ff in the last two digits. But the language of the standard is bit-based, and nothing requires alignment. Prefixes like /50 or /53 are valid. Calculations should not assume a digit boundary, and documentation should state the prefix length every time a block is named.
Documentation prefix and boundary arithmetic only
The arithmetic here covers network and boundary calculation for a documentation address, and it recommends no subnet size. The prefix 2001:db8::/32, assigned for documentation in RFC 3849, was chosen so no live network is affected. Nothing in the worksheet confirms that an address is assigned, reachable or in use. If you plan a real allocation, decide the prefix length from the number of subnets you need and the policy of whoever delegates the block, then use the calculator to verify that your written boundaries match the bits.
A routine for any prefix length
A method that works for every prefix saves time. Divide the prefix by 16 to find the number of complete groups, and note the remainder r. Copy the complete groups unchanged. Take the next group, write it as 16 binary digits, keep the first r bits, set the rest to zero and convert back to hex. Set every later group to zero and compress the result. For 2001:db8:abcd:1234::1 with prefix 52, 52 divided by 16 gives 3 with remainder 4, so copy 2001, db8 and abcd, keep 4 bits of 1234, which gives 1000, and zero the rest. Doing the same for prefix 49 gives the first bit only, 0, so the group becomes 0000.
Reproduce the checks
Whole-group prefix
Open the Ipv6 Subnet Calculator and enter:
- IP address
2001:db8:abcd:1234::1- Prefix length
48
Expected output:
Network
2001:db8:abcd::Three full hexadecimal groups are retained.
Partial-group prefix
Open the Ipv6 Subnet Calculator and enter:
- IP address
2001:db8:abcd:1234::1- Prefix length
52
Expected output:
Network
2001:db8:abcd:1000::Four additional prefix bits retain one more hexadecimal digit.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08