Skip to content
Daily Dose of Utilities

Binary, Hex, Octal & Decimal Converter

To convert decimal to binary, divide by 2 repeatedly and read the remainders from the last to the first. 255 in binary is 11111111, in octal 377 and in hexadecimal FF.

Binary (base 2)
1111 1111
Octal (base 8)
377
Decimal (base 10)
255
Hexadecimal (base 16)
FF

Show the math

  1. 1

    Decimal to binary: divide by 2 repeatedly

    255 ÷ 2 = 127 r 1 · 127 ÷ 2 = 63 r 1 · 63 ÷ 2 = 31 r 1 · 31 ÷ 2 = 15 r 1 · 15 ÷ 2 = 7 r 1 · 7 ÷ 2 = 3 r 1 · 3 ÷ 2 = 1 r 1 · 1 ÷ 2 = 0 r 1

    Keep dividing by the new base. The remainders, read from the last one back to the first, are the digits.

    = 1111 1111₂

Read the steps as text
  1. Decimal to binary: divide by 2 repeatedly. 255 ÷ 2 = 127 r 1 · 127 ÷ 2 = 63 r 1 · 63 ÷ 2 = 31 r 1 · 31 ÷ 2 = 15 r 1 · 15 ÷ 2 = 7 r 1 · 7 ÷ 2 = 3 r 1 · 3 ÷ 2 = 1 r 1 · 1 ÷ 2 = 0 r 1 Keep dividing by the new base. The remainders, read from the last one back to the first, are the digits.

How number bases work

In base 10, each position is worth ten times the one to its right: ones, tens, hundreds. Other bases work the same way with a different multiplier. In binary (base 2) the positions are worth 1, 2, 4, 8, 16 and so on, and only the digits 0 and 1 are used. Hexadecimal (base 16) needs sixteen digits, so it uses 0–9 and then A–F for ten to fifteen.

To convert any base to decimal, multiply each digit by the base raised to its position (counting from 0 on the right) and add the results: FF in hex is 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255.

Converting from decimal

To go from decimal to another base, divide by the new base, write down the remainder, and repeat with the quotient until it reaches 0. Reading the remainders from the last one back to the first gives the digits. 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1, so 13 is 1101 in binary.

Programmers use hexadecimal because each hex digit maps to exactly four binary digits, making long binary values much shorter to read: 1111 1111 is FF. The converter uses exact whole-number arithmetic, so even 64-bit values like 18,446,744,073,709,551,615 (FFFF FFFF FFFF FFFF) convert without rounding.

Frequently asked questions

How do I convert binary to decimal?
Multiply each digit by 2 raised to its position, counting from 0 on the right, and add them up. 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 11.
What is 255 in hexadecimal?
FF. 255 = 15 × 16 + 15, and F stands for 15. It's the largest value that fits in one byte.
Why does hexadecimal use letters?
Base 16 needs sixteen different digits, but we only have ten numerals, so A to F stand for 10 to 15.
Can I enter numbers with a 0x prefix?
Yes. Prefixes like 0x for hex and 0b for binary are ignored, and so are spaces or underscores used to group digits.

Related tools