Arte SheetsLearn. Try. Understand.

Statistical & Engineering

IPv4 CIDR Subnet Usable Host Count & 8-Bit Binary Octet Conversion Formula

Calculate total and usable IPv4 addresses for any /8–/32 CIDR prefix (2^(32 - prefix) - 2, honoring RFC 3021 /31 and /32 rules) and convert 0–255 octets to exact 8-bit binary strings.

Size VPC subnets and decode 8-bit IPv4 octets directly in your IPAM sheet!

In IPv4 Classless Inter-Domain Routing (CIDR), a /P prefix reserves P network bits and leaves (32 - P) host bits, yielding 2^(32 - P) total addresses. For standard subnets (/8 through /30), subtracting the network address and broadcast address leaves (2^(32 - P)) - 2 usable host IPs—while RFC 3021 point-to-point /31 links provide 2 usable addresses and /32 loopback routes represent 1 host!

To convert any decimal IPv4 octet D (0..255) into a zero-padded 8-bit binary string (replacing DEC2BIN, which caps signed 10-bit values and omits leading zeros unless padded), extract each bit weight 128..1 via MOD(INT(D / 2^b), 2)!

CIDR PrefixTotal IPv4 IPsUsable Host IPsFinal Mask Octet (Dec -> 8-Bit Bin)
/24 (255.255.255.0)2562540 -> 00000000
/26 (255.255.255.192)6462192 -> 11000000
/31 (Point-to-Point)22 (RFC 3021)254 -> 11111110

Usable IPv4 Host Count from CIDR Prefix Length (/8 to /32)

Computes (2^(32 - B2)) - 2 for /8../30, 2 for /31 point-to-point links, and 1 for /32 host routes.

=IF(OR(B2 < 8, B2 > 32), "Invalid CIDR Prefix", IF(B2 = 32, 1, IF(B2 = 31, 2, (2 ^ (32 - B2)) - 2)))

8-Bit Binary String from Decimal IPv4 Octet (0..255)

Decomposes decimal octet B3 into its exact 8-character binary bitstring.

=IF(OR(B3 < 0, B3 > 255), "Invalid Octet", MOD(INT(B3 / 128), 2) & MOD(INT(B3 / 64), 2) & MOD(INT(B3 / 32), 2) & MOD(INT(B3 / 16), 2) & MOD(INT(B3 / 8), 2) & MOD(INT(B3 / 4), 2) & MOD(INT(B3 / 2), 2) & MOD(B3, 2))

Try the example

Use the original values or change them to test your understanding.

Further reading