keepcalculator

06 Numbers and Powers

Binary and Decimal Numbers in Networking

Card No. 06·8063 · Updated · Standard formula, shown below

Binary and decimal numbers are the two numbering systems you must understand to work with IP addresses, subnet masks, and network configuration. Binary (base-2) is how computers and network devices represent all data, while decimal (base-10) is the familiar format used in IPv4 addresses. This article explains how both systems work, how to convert between them, and why networking professionals need this skill.

Why Networking Uses Binary

Every piece of data on a network—whether it is a web page, an email, or a video stream—is ultimately a sequence of bits. A bit is a single binary digit, either 0 or 1. Network devices use binary because their hardware is built from transistors that have two stable states: on (1) and off (0). This simplicity makes binary reliable and easy to implement in electronic circuits.

In networking, binary appears in several key places:

  • IP addresses – IPv4 addresses are 32-bit numbers, usually written in dotted decimal notation (e.g., 192.168.1.1). Each octet is an 8-bit binary number.
  • Subnet masks – A subnet mask (e.g., 255.255.255.0) is also a 32-bit binary number that tells a device which part of an IP address is the network portion and which is the host portion.
  • MAC addresses – These are 48-bit addresses, often written in hexadecimal (base-16), but they are stored and processed as binary.
  • Routing tables and packet headers – Routers read binary values to determine where to forward packets.

Without understanding binary, you cannot truly understand how subnetting works or why certain IP address ranges behave the way they do.

How Binary Numbers Work

Binary is a positional number system with a base of 2. Each digit (bit) represents a power of 2, starting from the rightmost bit as 20 (which equals 1). Moving left, each position doubles the value: 21=2, 22=4, 23=8, and so on.

For example, the binary number 1011 is calculated as:

  • 1 × 23 = 8
  • 0 × 22 = 0
  • 1 × 21 = 2
  • 1 × 20 = 1
  • Total = 8 + 0 + 2 + 1 = 11 in decimal

An 8-bit binary number can represent values from 00000000 (0) to 11111111 (255). That is why each octet in an IPv4 address ranges from 0 to 255. There are 256 possible values because 28 = 256.

How Decimal Numbers Work

Decimal is the base-10 system we use in everyday life. It uses ten digits (0–9), and each position represents a power of 10. For example, the number 345 means:

  • 3 × 102 = 300
  • 4 × 101 = 40
  • 5 × 100 = 5
  • Total = 345

In networking, decimal is used primarily for human readability. IPv4 addresses are written as four decimal numbers separated by dots, such as 192.168.1.1. Each of those numbers is actually an 8-bit binary value, but we write it in decimal to make it easier to read and remember.

Converting Between Binary and Decimal

Converting between binary and decimal is a core skill for network configuration and troubleshooting. Here are the standard methods:

Binary to Decimal

Write the binary number, then add up the powers of 2 for every position that has a 1. For example, convert 11001010:

  • Positions: 128, 64, 32, 16, 8, 4, 2, 1
  • Bits: 1, 1, 0, 0, 1, 0, 1, 0
  • Add: 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 = 202

Decimal to Binary

Divide the decimal number by 2 repeatedly, recording the remainders. Read the remainders from bottom to top. For example, convert 202 to binary:

  1. 202 ÷ 2 = 101 remainder 0
  2. 101 ÷ 2 = 50 remainder 1
  3. 50 ÷ 2 = 25 remainder 0
  4. 25 ÷ 2 = 12 remainder 1
  5. 12 ÷ 2 = 6 remainder 0
  6. 6 ÷ 2 = 3 remainder 0
  7. 3 ÷ 2 = 1 remainder 1
  8. 1 ÷ 2 = 0 remainder 1
  9. Read bottom to top: 11001010

You can also use the subtraction method: subtract the largest power of 2 that fits, mark a 1, and continue with the remainder.

Subnetting and Binary Math

Subnetting is where binary becomes essential. A subnet mask determines how many bits of an IP address are used for the network and how many for hosts. For example, the mask 255.255.255.0 in binary is:

11111111.11111111.11111111.00000000

The 1s represent the network portion, and the 0s represent the host portion. The number of host bits determines how many usable addresses are in that subnet. If you have n host bits, the number of usable host addresses is 2n – 2 (subtracting the network address and broadcast address).

For instance, with a /24 subnet (255.255.255.0), you have 8 host bits, so 28 – 2 = 254 usable addresses. This is why a typical home network has 254 usable IP addresses.

To find the network address of an IP, you perform a bitwise AND operation between the IP address and the subnet mask. For example, IP 192.168.1.130 with mask 255.255.255.0:

  • IP in binary: 11000000.10101000.00000001.10000010
  • Mask in binary: 11111111.11111111.11111111.00000000
  • AND result: 11000000.10101000.00000001.00000000 = 192.168.1.0

That tells you the network address is 192.168.1.0.

Common Mistakes and Misconceptions

Beginners often confuse the number of bits with the number of hosts. For example, a /30 subnet has 2 host bits, which gives 22 – 2 = 2 usable addresses. Some people mistakenly think it gives 4 usable addresses, forgetting that the network and broadcast addresses are not usable.

Another common mistake is mixing up binary and decimal when working with subnet masks. A mask of 255.255.255.0 is often written as /24, but that does not mean the decimal number 24; it means 24 bits are set to 1 in the binary mask. Always convert to binary when doing subnet calculations.

A frequent misconception is that binary is only for programmers. In reality, network administrators, security analysts, and IT support staff all need to read binary when configuring routers, firewalls, and access control lists. Even a simple task like setting a static IP address requires understanding that the numbers in the address are just decimal representations of binary octets.

Practical Tips for Learning and Using Binary

Here are some strategies to become comfortable with binary in a networking context:

  • Memorize the powers of 2 up to 28 (1, 2, 4, 8, 16, 32, 64, 128, 256). This will speed up conversions.
  • Practice converting the decimal numbers 0–255 to binary. These are exactly the values you see in IP octets.
  • Use the /prefix notation (e.g., /24) instead of the dotted decimal mask when possible—it directly tells you how many bits are network bits.
  • When subnetting, always start by writing out the binary mask and the IP address. This avoids errors.
  • Use online conversion tools for quick checks, but do the math by hand when studying to build understanding.

Also, remember that hexadecimal (base-16) is used for MAC addresses and IPv6. Hexadecimal is a shorthand for binary: each hex digit represents exactly 4 bits. For example, the hex digit A equals binary 1010. Knowing this makes it easier to work with MAC addresses and IPv6.

Frequently Asked Questions

Why are IP addresses written in decimal if computers use binary?

Decimal is used for human convenience. An address like 192.168.1.1 is much easier to remember and type than its binary equivalent, 11000000.10101000.00000001.00000001. Computers convert the decimal input to binary internally, but the decimal form is just a user-friendly interface.

What is the difference between a bit and a byte in networking?

A bit is a single binary digit (0 or 1). A byte is a group of 8 bits. In networking, speeds are often measured in bits per second (bps), while file sizes are measured in bytes. One byte equals 8 bits, so a 100 Mbps connection can theoretically transfer about 12.5 megabytes per second.

How do I convert a subnet mask like 255.255.255.0 to /notation?

Convert each octet to binary and count the 1s. 255 is 11111111, so 255.255.255.0 becomes 11111111.11111111.11111111.00000000, which has 24 ones. Therefore, it is a /24 subnet. This is why /24 is equivalent to 255.255.255.0.

What does the network address and broadcast address mean?

The network address is the first address in a subnet and identifies the subnet itself. The broadcast address is the last address and is used to send data to all devices in that subnet. Neither can be assigned to a host. For example, in the subnet 192.168.1.0/24, the network address is 192.168.1.0 and the broadcast address is 192.168.1.255.

Can I use a decimal calculator for binary conversions?

Yes, but you need to know the conversion method. Many standard calculators have a programmer mode that can convert between decimal, binary, and hexadecimal. Alternatively, you can use online converters, but understanding the manual process is important for networking exams and troubleshooting.

Why do we subtract 2 when calculating usable hosts?

In any subnet, two addresses are reserved: the network address (all host bits are 0) and the broadcast address (all host bits are 1). These cannot be assigned to individual devices. So the total number of usable host addresses is 2n – 2, where n is the number of host bits.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →