Binary numbers are the foundation of every computation your computer performs. Even if you never write low-level code, understanding binary, decimal, octal, and hexadecimal helps you make sense of bitwise operations, file permissions, memory addresses, colour codes, and network configurations.
This guide explains the four number systems, how to convert between them step by step, two's complement for negative numbers, and how to use the free Binary Converter tool to convert instantly.
Advertisement
The four number systems
| System | Base | Digits | Common use |
|---|---|---|---|
| Binary | 2 | 0, 1 | CPU instructions, bitwise operations, flags |
| Octal | 8 | 0โ7 | Unix file permissions (chmod 755) |
| Decimal | 10 | 0โ9 | Human-readable numbers, general use |
| Hexadecimal | 16 | 0โ9, AโF | Color codes, memory addresses, byte data |
How binary to decimal conversion works
Each binary digit represents a power of 2, starting from 2โฐ (= 1) on the right. To convert to decimal, multiply each bit by its positional power of 2 and add the results:
Binary: 1 0 1 1
Position: 3 2 1 0
Value: 2ยณ 2ยฒ 2ยน 2โฐ
8 0 2 1
1ร8 + 0ร4 + 1ร2 + 1ร1 = 11 (decimal)The same logic applies going the other direction. To convert decimal to binary, repeatedly divide by 2 and collect the remainders from bottom to top.
Conversion reference table
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 42 | 101010 | 52 | 2A |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
Two's complement and negative numbers
Standard binary can only represent non-negative integers. Two's complement is the technique used by CPUs to represent negative numbers using the same binary format:
1. Start with the positive number: +5 in 8-bit binary: 00000101
2. Invert all bits (bitwise NOT): 11111010
3. Add 1 to the result: 11111011 โ this is -5 in two's complement
Why developers need to understand binary
Bitwise operations
AND, OR, XOR, NOT, shift operations work on individual bits. Common in performance-critical code, cryptography, and flags.
Unix permissions
chmod 755 = binary 111 101 101. Each group of 3 bits controls read, write, and execute for owner, group, others.
CSS color codes
#FF5733 = R:255 G:87 B:51 in decimal. Each pair of hex digits is one byte (0โ255).
IP addresses and subnets
Subnet masks like 255.255.255.0 are binary AND masks: 11111111.11111111.11111111.00000000.
Bit flags and enums
Representing multiple boolean states as a single integer using bit positions โ common in database columns and API flags.
Data encoding
Base64, UTF-8, ASCII โ all encoding schemes work by converting data to and from binary.
Frequently asked questions
What is binary?
Binary is a base-2 number system that uses only two digits: 0 and 1. Every value in a computer is ultimately stored and processed as binary. Groups of 8 bits form a byte, which can represent 256 different values (0โ255).
How do you convert binary to decimal manually?
Each binary digit represents a power of 2, starting from 2โฐ at the right. Multiply each bit by its positional power and add the results. For example, 1011 = (1ร8) + (0ร4) + (1ร2) + (1ร1) = 11 in decimal.
What is hexadecimal used for?
Hexadecimal (base 16) uses digits 0โ9 and letters AโF. Each hex digit represents exactly 4 bits, making it a compact notation for binary values. Common uses include HTML/CSS color codes (#FF5733), memory addresses, and binary data in debuggers.
What is two's complement?
Two's complement is the standard method for representing signed integers in binary. To negate a number: invert all bits and add 1. For example, in 8-bit binary, +5 is 00000101 and -5 is 11111011. This allows CPUs to use the same addition circuitry for positive and negative numbers.
Why do computers use binary?
Computers use binary because electronic circuits have two stable states: on (1) and off (0), represented by voltage levels. Binary arithmetic is also simple to implement in hardware using logic gates (AND, OR, NOT, XOR).
What is the difference between binary and hex?
Binary (base 2) uses only 0 and 1. Hexadecimal (base 16) uses 0โ9 and AโF. Because 16 = 2โด, each hex digit corresponds to exactly 4 binary digits โ making hex a compact shorthand for binary values.
Convert binary numbers now
Free binary converter โ convert between binary, decimal, octal, and hex instantly. No sign-up, nothing stored.
Open Binary Converter โ