Skip to the tool
Binary Translator Free tools

Number systems: binary, octal, decimal and hex

A number system is a way of writing numbers with a fixed set of digits. Computing uses four: binary, octal, decimal and hexadecimal. Convert any number between them in the box, then compare them below.

Updated · Written and checked by Murugan Vellaichamy

Waiting for input

Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.

Result
Try:

The four number systems

SystemBaseDigitsPlace values255 written in itPrefix in code
Binary20 11, 2, 4, 8, 16 …111111110b
Octal80 to 71, 8, 64, 512 …3770o
Decimal100 to 91, 10, 100, 1000 …255none
Hexadecimal160 to 9, A to F1, 16, 256, 4096 …FF0x

The prefixes are the ones JavaScript uses (ECMA-262, section 12.9.3); many other languages use the same ones.

0 to 16 in all four systems

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010

Place values: the idea behind every base

In any number system, each place is worth the base times the place to its right.

In decimal, 352 is 3 hundreds, 5 tens and 2 ones. In hexadecimal, 352 means 3 × 256 + 5 × 16 + 2 = 850. The digits are the same; the base changes what they are worth. That is why it helps to write the base as a small subscript, 35216, or to use a prefix such as 0x.

How to convert between number systems

From → toMethodConverter
Any base → decimalMultiply each digit by its place value and addbinary, octal, hex
Decimal → any baseDivide by the base repeatedly; read the remainders from the bottom upbinary, octal, hex
Binary ↔ hexGroup bits in fours; each group is one hex digitbinary to hex, hex to binary
Binary ↔ octalGroup bits in threes; each group is one octal digitbinary to octal, octal to binary
Octal ↔ hexGo through binary: three bits per octal digit, then regroup in foursbase converter

Why does computing use four number systems?

Computers store everything in binary, because their circuits work with two states. People think in decimal.

Hexadecimal and octal sit in between: 16 and 8 are powers of 2, so each hex digit is exactly four bits and each octal digit exactly three. That makes them short, exact ways of writing binary. Hex is the common choice today, because a byte is exactly two hex digits; octal survives in places such as Unix file permissions.

Sources and method

Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.

Questions

What are the four number systems?

Binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16).

Which number system do computers use?

Binary. Octal and hexadecimal are shorthand that people use to read and write binary more easily.

What is a number system converter?

A tool that rewrites a number from one base into another, such as decimal to binary. The box on this page converts between any bases from 2 to 36.

Why is 10 not always ten?

Because “10” means one of the base and nothing more. In binary 10 is two, in octal it is eight and in hex it is sixteen.

More converters

Copied