Binary is the language of computers. Every piece of data — text, images, video, code — is ultimately represented as sequences of 0s and 1s. Whether you're a computer science student, a network engineer configuring subnet masks, or a programmer working with bitwise operations, understanding binary arithmetic is essential. This guide walks you through binary number conversions, arithmetic operations, and how to use a binary calculator effectively.
Binary is a base-2 number system. While decimal (base-10) uses ten digits (0–9), binary uses only two: 0 and 1. Each position in a binary number represents a power of 2, starting from the right.
| Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Power of 2 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Example: 10110101 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
Value: 128 + 32 + 16 + 4 + 1 = 181 in decimal
A single binary digit is called a bit. Eight bits make a byte, which can represent values from 0 to 255. This is why you'll often see binary numbers written in groups of eight.
To convert a binary number to decimal, multiply each bit by its corresponding power of 2 and sum the results.
The most reliable method is repeated division by 2. Divide the number by 2, record the remainder, and continue with the quotient until it reaches 0. The binary result is the remainders read in reverse order.
| Division | Quotient | Remainder |
|---|---|---|
| 42 ÷ 2 | 21 | 0 |
| 21 ÷ 2 | 10 | 1 |
| 10 ÷ 2 | 5 | 0 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Read remainders bottom to top: 101010
Binary converts easily to hexadecimal (base-16) because 16 is a power of 2. Group binary digits in sets of four (starting from the right) and map each group to its hex equivalent.
0101 1110 0110Similarly, group binary digits in sets of three for octal conversion:
101 110 110Binary addition follows simple rules. There are only four possible combinations:
| 0 + 0 | 0 + 1 | 1 + 0 | 1 + 1 |
|---|---|---|---|
| 0 | 1 | 1 | 10 (carry 1) |
1011 (11)
+ 1101 (13)
-------
11000 (24)
Working right to left: 1+1=10 (write 0, carry 1), 1+0+1=10, 0+1+1=10, 1+1+1=11. Result: 11000
Binary subtraction uses borrowing, similar to decimal subtraction:
| 0 − 0 | 1 − 0 | 1 − 1 | 0 − 1 |
|---|---|---|---|
| 0 | 1 | 0 | 1 (borrow 1) |
1101 (13)
- 1010 (10)
-------
0011 (3)
Binary multiplication is simpler than decimal — you only multiply by 0 or 1:
110 (6)
× 101 (5)
-------
110 (6 × 1)
000 (6 × 0, shifted)
110 (6 × 1, shifted twice)
-------
11110 (30)
Binary long division follows the same pattern as decimal long division, but you only need to check if the divisor fits into the current portion of the dividend (it either does or doesn't).
Programmers use bitwise operations to manipulate individual bits within binary numbers. These are fundamental in systems programming, cryptography, and embedded systems.
| Operation | Symbol | Example | Result |
|---|---|---|---|
| AND | & | 1100 & 1010 | 1000 |
| OR | | | 1100 | 1010 | 1110 |
| XOR | ^ | 1100 ^ 1010 | 0110 |
| NOT | ~ | ~1100 | 0011 (in 4-bit) |
| Left Shift | << | 0010 << 2 | 1000 |
| Right Shift | >> | 1000 >> 2 | 0010 |
Network engineers use binary to calculate subnet masks. For example, 255.255.255.0 in binary is 11111111.11111111.11111111.00000000, which represents a /24 network with 256 possible addresses.
Linux file permissions (like chmod 755) are based on octal representations of binary permission bits:
7 = 111 = read + write + execute5 = 101 = read + execute6 = 110 = read + writeRGB color codes like #8B5CF6 are hexadecimal representations of binary color values. Each pair of hex digits represents one byte of the RGB value.
Perform binary addition, subtraction, multiplication, and division. Convert between binary, decimal, hex, and octal instantly.
Binary arithmetic might seem intimidating at first, but the rules are actually simpler than decimal arithmetic — there are far fewer combinations to memorize. Whether you're debugging a network issue, writing low-level code, or just curious about how computers work, mastering binary gives you a deeper understanding of the technology you use every day. Practice with a binary calculator, work through examples by hand, and soon binary will feel as natural as counting to ten.