What this calculator does
A number base determines how many digits are available before a new place value begins. Decimal uses ten, binary two, hexadecimal sixteen. The underlying quantity never changes: only its written representation does.
Binary and hexadecimal dominate computing for practical reasons. Binary matches the two states of a physical switch, and hexadecimal is a compact shorthand for it, since one hex digit corresponds to exactly four binary digits. That clean mapping is why memory addresses and colour codes are written in hex.
The formula
To convert to a base, divide repeatedly by that base and read the remainders in reverse. To convert from a base, multiply each digit by the base raised to its position. Bases above ten use letters A to Z for digits beyond 9.
| Term | Meaning |
|---|---|
| Base | How many distinct digits the system uses. |
| Binary | Base 2, using 0 and 1. |
| Octal | Base 8, using 0 to 7. |
| Hexadecimal | Base 16, using 0 to 9 and A to F. |
| Bit | One binary digit. |
The inputs explained
| Field | What to enter |
|---|---|
| Value | The value to convert, written in the source base. Hexadecimal letters may be upper or lower case. |
| From base | The base the value is currently written in. |
| To base | The base to convert it into. Every common base is shown in the results regardless. |
When to use it
Reading colour codes
A hex colour such as FF8800 is three bytes: red 255, green 136, blue 0. Converting each pair to decimal is what the code actually means.
Working with permissions and flags
Unix file permissions are octal because each digit maps to exactly three permission bits. 755 in octal is 111 101 101 in binary: read, write and execute for the owner, read and execute for everyone else.
Understanding memory addresses
Addresses are written in hex because each digit covers four bits, so a 32-bit address fits in eight characters instead of thirty-two.
Checking bit lengths
The bits-needed figure tells you how many binary digits a value requires, which is what determines whether it fits in a given data type.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
Common decimal values in other bases
Values that appear frequently in computing, shown across bases.
| Decimal | Binary | Octal | Hexadecimal | Bits needed |
|---|---|---|---|---|
| 10 | 1010 | 12 | A | 4 |
| 64 | 1000000 | 100 | 40 | 7 |
| 100 | 1100100 | 144 | 64 | 7 |
| 255 | 11111111 | 377 | FF | 8 |
| 1024 | 10000000000 | 2000 | 400 | 11 |
| 65535 | 1111111111111111 | 177777 | FFFF | 16 |
Reading hexadecimal back into decimal
Hexadecimal values of the kind found in colour codes and memory dumps.
| Hexadecimal | Decimal | Binary | Bits needed |
|---|---|---|---|
| A | 10 | 1010 | 4 |
| FF | 255 | 11111111 | 8 |
| 100 | 256 | 100000000 | 9 |
| 7FFF | 32,767 | 111111111111111 | 15 |
| FF8800 | 16,746,496 | 111111111000100000000000 | 24 |
| DEADBEEF | 3,735,928,559 | 11011110101011011011111011101111 | 32 |
Questions
Why does computing use binary?
Because a physical switch has two reliable states: on and off, high and low voltage. Two states can be distinguished robustly in the presence of noise, whereas ten distinct voltage levels could not.
Why hexadecimal rather than decimal?
Because 16 is a power of 2, so each hex digit corresponds to exactly four binary digits. Conversion is a lookup rather than a calculation, and long binary strings become compact and readable.
How do I convert binary to decimal by hand?
Multiply each digit by 2 raised to its position, counting from zero on the right, then add. 1011 is 8 + 0 + 2 + 1 = 11.
What do the letters in hexadecimal mean?
They are digits beyond 9: A is 10, B is 11, up to F which is 15. Base 36 continues the pattern all the way to Z as 35.
How many bits do I need for a number?
The bit length is the floor of log₂ of the number, plus one. The calculator reports it directly, which is what determines the smallest data type that will hold the value.
For the logarithms behind bit lengths, see the logarithm calculator. For data size units, use the digital storage converter.