If you have ever looked at a web color code like #4f46e5 and wondered what those letters and numbers mean, or if you have taken a computer science class and found yourself confused every time the topic switched from regular numbers to binary, this guide is for you. Number systems sound complicated but the core idea behind all of them is actually very simple, and once you get it, switching between binary, decimal, hexadecimal, and octal starts to feel natural.
Why Do Different Number Systems Exist
We use the decimal system in everyday life because we have ten fingers. Decimal is base 10, which means it uses ten digits - 0 through 9 - and each position in a number represents a power of ten. The number 245 means 2 hundreds, 4 tens, and 5 ones.
Computers, however, do not have fingers. They are built from electronic switches that can be either on or off - two states. This makes binary, which is base 2, the natural language of computers. Every piece of data a computer stores or processes is ultimately represented as a sequence of ones and zeros.
Hexadecimal exists because binary is hard for humans to read. A single byte of data requires eight binary digits. Writing out long strings of ones and zeros becomes tedious and error-prone. Hexadecimal, which is base 16, provides a much more compact way to represent the same information - a single hex digit represents exactly four binary digits, so one byte of data takes only two hex digits instead of eight binary ones.
Octal, which is base 8, was historically used in computing for similar reasons and still appears in specific contexts like Unix file permissions.
The Decimal System (Base 10)
This is what you already know. Ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. When you reach 9 and need to go higher, you add a new position to the left and start over. So 9 becomes 10, 99 becomes 100, and so on. Each position represents a power of ten - ones, tens, hundreds, thousands, and so forth.
The Binary System (Base 2)
Only two digits: 0 and 1. Every position represents a power of two instead of a power of ten. Starting from the right, the positions represent 1, 2, 4, 8, 16, 32, 64, 128, and so on.
To read the binary number 1011, you work from right to left. The rightmost position is 1 times 1, giving you 1. The next position is 1 times 2, giving you 2. The next is 0 times 4, giving you 0. The leftmost is 1 times 8, giving you 8. Add them up: 8 plus 2 plus 1 equals 11 in decimal. So 1011 in binary is 11 in decimal.
A single binary digit is called a bit. Eight bits make a byte. A byte can represent 256 different values - from 0 to 255 in decimal, or 00000000 to 11111111 in binary.
The Hexadecimal System (Base 16)
Sixteen digits: 0 through 9, then A through F. The letters A through F represent the values 10 through 15. This might look strange at first but it makes sense once you remember that a single digit needs to represent one of sixteen possible values, and we only have ten numeric symbols, so we borrow six letters.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 5 | 0101 | 5 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 255 | 11111111 | FF |
Hexadecimal shows up everywhere in computing. Web color codes use hex - the color #4f46e5 is three pairs of hex digits representing the red, green, and blue values of the color. Memory addresses in programming are shown in hex. Error codes in Windows are hex values. Understanding hex makes many technical things much clearer.
The Octal System (Base 8)
Eight digits: 0 through 7. You will most commonly encounter octal in Unix and Linux file permission settings. When you see a permission like 755 in a terminal, those are octal digits. The 7 represents full permissions (read, write, execute), the first 5 represents read and execute for the group, and the second 5 represents read and execute for others.
How to Convert Between Number Systems
Converting by hand is a useful skill to understand conceptually, but for practical work, using a converter tool is much faster and less error-prone. Textaura's number converter handles all conversions between decimal, binary, hexadecimal, octal, BCD, and Gray Code instantly. You type a value in any field and all the others update in real time.
Converting decimal to binary by hand
Divide the decimal number by 2 repeatedly, writing down the remainder each time. When you reach 0, read the remainders from bottom to top. For example, to convert 13 to binary: 13 divided by 2 is 6 remainder 1. 6 divided by 2 is 3 remainder 0. 3 divided by 2 is 1 remainder 1. 1 divided by 2 is 0 remainder 1. Reading the remainders from bottom to top gives 1101, which is 13 in binary.
Converting binary to hexadecimal
Group the binary digits into sets of four from right to left, padding with leading zeros if needed. Then convert each group of four bits to its hex equivalent. For example, the binary number 11010110 becomes 1101 and 0110. 1101 in decimal is 13, which is D in hex. 0110 is 6. So 11010110 in binary is D6 in hexadecimal.
Convert between binary, decimal, hex, octal, BCD and Gray Code instantly - free online tool.
Open Number ConverterWhere You Will Actually See These Number Systems
Binary comes up in computer science courses, in discussions of data storage and file sizes, in networking (subnet masks in binary form), and in programming when working with bitwise operations or reading hardware documentation.
Hexadecimal appears in web development (color codes), in programming (memory addresses, Unicode code points, error codes), in cryptography (hash values), and in any low-level technical context where binary would be too verbose.
Octal appears mainly in Unix and Linux contexts, particularly file permissions, and in some older programming languages and hardware documentation.
Frequently Asked Questions
Why do computers use binary instead of decimal?
Because the electronic components that make up a computer - transistors - have two stable states: on and off. These map perfectly to 1 and 0. Building hardware that reliably distinguishes ten different states rather than two would be significantly more complex and error-prone.
What does 0x mean before a number?
The 0x prefix is a convention used in programming to indicate that the number following it is in hexadecimal. So 0xFF means FF in hexadecimal, which is 255 in decimal.
What is the difference between a bit and a byte?
A bit is the smallest unit of data - a single binary digit, either 0 or 1. A byte is eight bits. A byte can represent 256 different values. File sizes, RAM, and storage are typically measured in bytes and their multiples: kilobytes, megabytes, gigabytes, and so on.
How many digits does a byte take in each number system?
One byte takes 8 digits in binary, 3 digits in decimal (up to 255), and 2 digits in hexadecimal (up to FF). This compactness is exactly why programmers prefer hexadecimal for representing binary data.