IP Address Formats: Binary, Decimal, and Hexadecimal
The Structure of an IPv4 Address
An IPv4 address is a 32-bit number that uniquely identifies a device on a network. We typically write it in dotted-decimal notation as four numbers separated by periods, like 192.168.1.100. Each of those four numbers, called octets, represents 8 bits and can range from 0 to 255. This notation was designed to be human-readable, but computers work with the same address as a raw 32-bit binary number.
Understanding the binary representation is essential for networking tasks like subnetting, configuring access control lists, and troubleshooting connectivity issues. The decimal format we see is just a convenience. Underneath, every IP address is a sequence of 32 ones and zeros that routers and switches use to make forwarding decisions.
Binary Representation
Each octet of an IP address converts to an 8-bit binary number. The decimal value 192 becomes 11000000 in binary. The value 168 becomes 10101000. Together, the address 192.168.1.100 is 11000000.10101000.00000001.01100100 in binary. Each bit position represents a power of 2, from 128 on the left down to 1 on the right.
To convert from decimal to binary, you work through each power of 2 starting from 128. If 128 fits into your number, write a 1 and subtract 128. If not, write a 0. Continue with 64, 32, 16, 8, 4, 2, and 1. For example, 200 is greater than 128, so the first bit is 1, leaving 72. Then 72 is greater than 64, so the next bit is 1, leaving 8. Continue this process to get 11001000.
Hexadecimal Representation
Hexadecimal, or base-16, provides a more compact way to represent binary data. Each hex digit represents exactly 4 bits, so a full 8-bit octet can be written as just two hex characters. The hex digits 0 through 9 represent values 0 through 9, and A through F represent values 10 through 15.
The IP address 192.168.1.100 in hexadecimal is C0.A8.01.64, sometimes written without dots as C0A80164. Hexadecimal is particularly useful in programming and low-level networking because it maps cleanly to binary while being shorter to write. You will encounter hex IP representations in packet captures, firewall logs, and network programming contexts.
Why Different Formats Matter
Each representation format has practical uses in different contexts:
- Decimal notation is standard for configuration, documentation, and everyday communication
- Binary notation is essential for understanding subnetting, wildcard masks, and bitwise operations
- Hexadecimal notation appears in programming, packet analysis, and IPv6 addressing
- Integer notation (the full 32-bit number as a single decimal) is used in some databases and APIs
Being comfortable with all three formats makes you more effective at network troubleshooting and configuration. When you see a subnet mask of 255.255.240.0, understanding its binary form of 11111111.11111111.11110000.00000000 immediately reveals that it is a /20 network with 4,094 usable host addresses.
Subnetting Basics and Binary Math
Subnetting divides a larger network into smaller segments, and it relies entirely on binary math. A subnet mask determines which portion of an IP address identifies the network and which portion identifies the individual host. When both the IP address and subnet mask are written in binary, the boundary between network and host bits becomes visually clear.
For example, with a /24 subnet mask (255.255.255.0), the first 24 bits identify the network and the last 8 bits identify hosts. This allows 254 usable addresses per subnet. A /16 mask uses the first 16 bits for the network, allowing 65,534 hosts. Understanding this binary relationship is the foundation for designing networks of any size, from small office LANs to enterprise campus networks.
Converting Between Formats
Converting between decimal, binary, and hexadecimal is a fundamental skill for anyone working with networks. The key is to treat each octet independently. Convert each decimal octet to its 8-bit binary equivalent, then group the binary digits into 4-bit nibbles for hex conversion. Going the other direction, convert each hex pair to 8 bits, then convert those 8 bits to a decimal number.
With practice, common values become second nature. You will quickly recognize that 255 is 11111111 in binary and FF in hex, that 128 is 10000000 and 80, or that 0 is 00000000 and 00. For less familiar values, an IP address converter handles the translation between decimal, binary, and hex instantly, which is useful when you need to verify a subnet calculation or convert an address format for a configuration file.