Skip to content
SacaCuenta

Binary Converter

Convert numbers between binary, decimal, hexadecimal and octal in any direction. Enter a number, pick its base, and you'll see the other three instantly, along with the steps.

FreeNo sign-upInstant resultsUpdated:

Converter

Accepts 0b, 0x and 0o prefixes, spaces and a minus sign.

Decimal

42

Base 10

Hexadecimal

2A

Base 16

Octal

52

Base 8

Bits needed
6
Hex digits
2

From binary to decimal

1×2^5 + 0×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 0×2^0

= 42

Each digit is worth its value times the base raised to its position. One hex digit is exactly 4 bits and one octal digit is 3, which is why they're grouped that way.

For estimates only. Double-check the numbers before making important decisions.

Binary, decimal, hex and octal

BaseDigits used255 written in this base
Binary (base 2)0 and 11111 1111
Octal (base 8)0–7377
Decimal (base 10)0–9255
Hexadecimal (base 16)0–9 and A–FFF

In hexadecimal, the letters A through F stand for the values 10 through 15.

How to convert binary to decimal

Each digit is worth its value times the base raised to its position. Positions are counted from the right, starting at 0. Add up the results.

value = Σ digit × base^position
1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11

The same method works for any base: FF₁₆ = 15×16¹ + 15×16⁰ = 240 + 15 = 255.

How to convert decimal to binary

Divide the number by 2 over and over, writing down each remainder, until you reach 0. Then read the remainders from the bottom up. For 42:

DivisionQuotientRemainder
42 ÷ 2210
21 ÷ 2101
10 ÷ 250
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading the remainders from bottom to top gives 101010. To convert to hex or octal, divide by 16 or 8 instead.

Binary to hex and octal shortcut

One hex digit is exactly 4 bits, and one octal digit is exactly 3 bits. So you can convert binary to hex by splitting it into groups of 4 from the right (1010 1111 → A F → AF), and to octal with groups of 3 (101 010 → 5 2 → 52). That's why the calculator groups binary digits in fours.

Accepted input formats

  • Prefixes 0b (binary), 0o (octal) and 0x (hex), as used in most programming languages.
  • Spaces or underscores to separate groups, like 1111_0000.
  • A minus sign in front for negative numbers.
  • Up to 128 digits, converted with exact integer math (no rounding).

Example

Binary 101010 is 42 in decimal, 2A in hexadecimal and 52 in octal. Decimal 255 is 1111 1111 in binary and FF in hex.

  1. 101010₂ = 32 + 8 + 2 = 42
  2. 42 = 2 × 16 + 10, and 10 is A in hex → 2A₁₆
  3. 42 = 5 × 8 + 2 → 52₈
  4. 255 = 15 × 16 + 15 → FF₁₆

Common mistakes

  • Reading the remainders from top to bottom when converting decimal to binary. They must be read bottom up.
  • Typing the letter O instead of the digit 0, or the letter I or l instead of 1.
  • Grouping bits from the left when converting to hex. Always start from the right and pad the leftmost group with zeros.

Frequently asked questions

How do I convert binary to decimal?

Multiply each bit by 2 raised to its position (counting from 0 on the right) and add the results. For 1101: 8 + 4 + 0 + 1 = 13.

What is 255 in binary?

255 is 11111111 in binary: eight 1s. It's the largest value that fits in one byte, and FF in hex.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and read the remainders from the bottom up, writing 10–15 as A–F. For 255: 255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15, giving FF.

Why is hexadecimal used so much in computing?

Because each hex digit maps to exactly 4 bits, so a byte (8 bits) is always 2 hex digits. It's a compact, readable way to write binary, which is why you see it in color codes like #FF8800 and memory addresses.

How are negative numbers shown?

This tool puts a minus sign in front of the number. Computers usually store negatives in two's complement, which depends on the number of bits (8, 16, 32 or 64), so the same value can look different from one system to another.