Calculator: Minimal covering IPv4 prefix

Enter the labelled inputs to calculate: Result CIDR; First address; Last address; Count.

Result CIDR
192.168.1.0/24
First address
192.168.1.0
Last address
192.168.1.255
Count
256

How the calculation works

p=32−⌈log₂((A XOR B)+1)⌉

IPv4 uses strict dotted decimal. IPv6 accepts embedded IPv4 tails and compresses the longest leftmost zero run. Zone identifiers are excluded. Prefix tools describe address ranges, not routability or host allocation policy.

Values must satisfy the formula’s domain. Nonzero results too small or too large for reliable representation are rejected.

Frequently asked questions

How is the result calculated?

p=32−⌈log₂((A XOR B)+1)⌉

What assumptions apply?

IPv4 uses strict dotted decimal. IPv6 accepts embedded IPv4 tails and compresses the longest leftmost zero run. Zone identifiers are excluded. Prefix tools describe address ranges, not routability or host allocation policy.

How precise are the displayed results?

Numerical results show up to ten significant digits. Rounding does not improve the accuracy of the input measurements or the model. Values must satisfy the formula’s domain. Nonzero results too small or too large for reliable representation are rejected.

How we verified this calculator

The calculator is checked against 3 reference cases computed independently from the sources below. Last passed: .

# Inputs Expected result
1
Address A = 192.168.1.10
Address B = 192.168.1.200
Result CIDR: 192.168.1.0/24
First address: 192.168.1.0
Last address: 192.168.1.255
Count: 256
2
Address A = 10.0.0.1
Address B = 10.0.3.4
Result CIDR: 10.0.0.0/22
First address: 10.0.0.0
Last address: 10.0.3.255
Count: 1024
3
Address A = 172.16.5.4
Address B = 172.16.5.4
Result CIDR: 172.16.5.4/32
First address: 172.16.5.4
Last address: 172.16.5.4
Count: 1

Sources

How we test our calculators →

Also try:

Back to category →