Number systems are the different ways of writing the same value. The quantity that decimal writes as 255, binary writes as 11111111, and hexadecimal writes as FF. These are not different numbers. They are the same amount in different notation. Computers rely on several of these notations at once, and knowing how they relate explains a great deal of what you see in code, in colour values, and in raw file data. This guide explains the four number systems you will actually meet, decimal, binary, hexadecimal, and octal, and how to convert between them.
In this guide
- Why computers use more than one number system
- Decimal: base 10, the system you already use
- Binary: base 2, how computers count
- Hexadecimal: base 16, binary made readable
- Octal: base 8, the older shorthand
- How to convert between number systems
- From text to numbers: ASCII and character codes
- Bitwise operations: working with bits directly
- Special encodings: BCD and Gray code
- Quick reference
- Frequently asked questions
Why computers use more than one number system
A computer is built from switches, and each switch is either off or on. Those two states are the two digits of binary, 0 and 1, and binary is the only system the hardware truly uses. Everything else exists for the people reading it.
Binary is correct but hard to read. A single byte is eight digits long, and a memory address can run past thirty. Hexadecimal packs that same information into a quarter of the digits, so programmers use hex to read and write what the machine stores as binary. Decimal is the system people count in day to day. Octal is an older shorthand that still appears in a few specific places. Each system carries the same information, written for whoever needs to read it.
Decimal: base 10, the system you already use
Decimal is the system you grew up with. It has ten digits, 0 through 9. Its proper name, base 10, describes the rule behind it: each place is worth ten times the place to its right. In the number 4253, the 3 is worth 3, the 5 is worth 50, the 2 is worth 200, and the 4 is worth 4000.
Nothing about base 10 is special to mathematics. We use it because people have ten fingers. A computer has no fingers, so it has no reason to count in tens, and internally it does not.
Binary: base 2, how computers count
Binary has two digits, 0 and 1, and each digit is called a bit. Each place is worth twice the place to its right: 1, 2, 4, 8, 16, and so on. To read a binary number, add the place values wherever a 1 sits.
The binary number 1101 has a 1 in the 8 place, the 4 place, and the 1 place, so it equals 8 plus 4 plus 1, which is 13 in decimal. Eight bits together make a byte, and one byte can hold any value from 0 to 255. Binary is exact and it matches the hardware directly, but it is long and easy to misread, which is the reason the other systems exist. To turn a binary value into everyday decimal, the binary to decimal converter does it instantly.
Hexadecimal: base 16, binary made readable
Hexadecimal, usually shortened to hex, has sixteen digits. The first ten are 0 through 9, and the next six are the letters A through F, where A stands for 10 and F stands for 15.
Hex matters because of how cleanly it fits binary: one hex digit is exactly four bits. That means a byte, which is eight bits, is always exactly two hex digits. The byte 11111111 is FF, and 00000000 is 00. This is why hex appears everywhere a person needs to read binary data. A colour written as #1D9E75 is three bytes shown as six hex digits, one pair each for red, green, and blue. The binary to hex converter turns a binary value into hex.
Octal: base 8, the older shorthand
Octal has eight digits, 0 through 7. One octal digit is exactly three bits, the same idea as hex but in smaller groups.
Octal was common on older computer systems and is now mostly a niche. It still appears in a few places, the best known being file permissions on Unix and Linux systems, where a permission written as 755 is an octal number. The binary to octal converter handles that conversion. For most modern work, hex has replaced octal.
How to convert between number systems
Converting by hand is straightforward arithmetic, but it is slow and easy to slip on, especially with long values. The practical approach is a converter.
The binary to decimal, binary to hex, and binary to octal converters each take a binary value and return it in the system you need. The full set lives in the binary tools category and the number tools category. Each one runs in your browser with no signup, and the value never leaves your device.
From text to numbers: ASCII and character codes
Number systems explain how a computer stores numbers. Text is stored the same way, also as numbers. Every letter, digit, and symbol is assigned a code by a standard called ASCII. The capital letter A is 65, lowercase a is 97, and the digit 0 is 48. Those codes are then held in binary, so the letter A becomes 01000001.
This is the bridge between the text you type and the bits on disk. The ASCII to binary converter shows a piece of text as its binary codes, the binary to text converter reverses it, and the ASCII to hex converter shows the same text as hex codes.
Bitwise operations: working with bits directly
Sometimes you need to work on the bits themselves rather than the value they represent. Bitwise operations compare two binary numbers one bit at a time. AND returns a 1 only where both inputs have a 1. OR returns a 1 where either input does. XOR returns a 1 where exactly one input does.
These three operations are the building blocks of low-level programming, permission flags, and simple encryption. The binary AND tool performs a bitwise AND on two values, the binary addition tool adds two binary numbers, and the bitwise hex calculator works directly on hexadecimal values.
Special encodings: BCD and Gray code
Two specialised encodings round out the picture. BCD, short for binary coded decimal, stores each decimal digit as its own four-bit group instead of converting the whole number at once. It is used where a value must map cleanly back to separate decimal digits, such as some clocks and numeric displays. The BCD to decimal converter handles it.
Gray code is a binary sequence arranged so that any two consecutive values differ by only one bit. That property prevents read errors in hardware like rotary encoders, where several bits changing at once could be misread. The binary to Gray code converter produces it.
Quick reference
| System | Base | Digits | One digit equals | Common use |
|---|---|---|---|---|
| Decimal | 10 | 0 to 9 | n/a | Everyday counting |
| Binary | 2 | 0 and 1 | 1 bit | How hardware stores everything |
| Octal | 8 | 0 to 7 | 3 bits | Unix file permissions |
| Hexadecimal | 16 | 0 to 9, A to F | 4 bits | Colours, memory, byte data |
Free number tools used in this guide
Frequently asked questions
Why do computers use binary?
Computer hardware is built from switches that are either off or on. Those two states map directly onto the two binary digits, 0 and 1, so binary is the natural system for the machine.
What is hexadecimal used for?
Hex is a short, readable way to write binary. One hex digit equals exactly four bits, which makes it ideal for colour codes, memory addresses, and raw byte data.
Is binary 1101 the same as decimal 1101?
No. Binary 1101 equals decimal 13. The same digits represent different values depending on the base they are written in.
What is a byte?
A byte is a group of eight bits. It can hold any value from 0 to 255, which is exactly two hexadecimal digits.
Where is octal still used?
The most common place is Unix and Linux file permissions, where a setting such as 755 is an octal number.