Skip to content

Binary and Hex Converter: Binary, Octal, Decimal and Hex

Convert numbers between binary, octal, decimal and hexadecimal. Learn place value in each base, step-by-step conversion methods and where each number system is used.

3 min read

We count in base 10 because we have ten fingers, but computers work in base 2, and programmers often use base 16 or base 8 as shorthand. Converting between these systems is a daily task in programming, networking and electronics. Our binary and hex converter turns a number in any of the four common bases into all the others at once. This guide explains how each system works and how to convert by hand.

How to use the converter

  1. Number: type the value.
  2. Input base: binary, octal, decimal or hex.

With the default 255 in decimal, the results are:

  • Hexadecimal: FF
  • Binary: 11111111
  • Octal: 377
  • Decimal: 255

Enter 1101 as binary and you get decimal 13, hex D and octal 15.

The four common bases

BaseNameDigits used
2Binary0, 1
8Octal0 to 7
10Decimal0 to 9
16Hexadecimal0 to 9, then A to F

In hex, A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.

Place value

Every base works the same way: each position is worth the base raised to a power, counting from 0 on the right.

Decimal 255: 2 × 10² + 5 × 10¹ + 5 × 10⁰ = 200 + 50 + 5.

Binary 1101: 1 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰ = 8 + 4 + 0 + 1 = 13.

Hex FF: 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255.

Octal 377: 3 × 64 + 7 × 8 + 7 × 1 = 192 + 56 + 7 = 255.

Converting decimal to another base

Divide repeatedly by the new base and write down the remainders. Read them from the bottom up.

Decimal 13 to binary:

  1. 13 ÷ 2 = 6 remainder 1
  2. 6 ÷ 2 = 3 remainder 0
  3. 3 ÷ 2 = 1 remainder 1
  4. 1 ÷ 2 = 0 remainder 1

Reading upward: 1101.

Decimal 200 to hex: 200 ÷ 16 = 12 remainder 8, and 12 ÷ 16 = 0 remainder 12 (C). Reading upward: C8.

Shortcut between binary and hex

Each hex digit is exactly four binary digits, so you can convert in groups without going through decimal.

HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

Binary 1011 0110 splits into 1011 (B) and 0110 (6), giving B6. Octal works the same way with groups of three bits: 11 111 111 is 3 7 7.

Where each base is used

  • Binary: how computers store everything. Each bit is on or off. The binary calculator does arithmetic and bitwise operations directly in base 2.
  • Hexadecimal: a compact way to write binary. Web colours (#FF8800), memory addresses, MAC addresses and byte values all use hex. The hex calculator adds and multiplies in base 16.
  • Octal: still used for Unix file permissions, such as chmod 755 (rwx r-x r-x).
  • Decimal: everyday human counting.

Useful values to remember

  • 1 byte = 8 bits, ranging from 0 to 255 (00 to FF in hex).
  • 2¹⁰ = 1,024, and 2¹⁶ = 65,536 (FFFF + 1).
  • An IPv4 address is four bytes, each 0 to 255. The IP subnet calculator shows the binary masks behind subnetting.
  • A web colour like #3366CC has red 0x33 = 51, green 0x66 = 102, blue 0xCC = 204.

Tips

  • Prefixes help avoid confusion: 0b for binary (0b1101), 0x for hex (0xFF), 0o or a leading 0 for octal.
  • Hex letters are not case-sensitive: ff and FF are the same.
  • Group long binary numbers in fours for readability.

Frequently asked questions

Why do computers use binary?

Electronic circuits are most reliable with two states, on and off. Binary maps directly onto those states.

Why do programmers use hexadecimal?

One hex digit represents exactly four bits, so a byte is always two hex digits. It is far shorter and easier to read than binary.

How do I convert hex to decimal quickly?

Multiply each digit by 16 raised to its position and add. For 2F: 2 × 16 + 15 = 47.

Can the converter handle large numbers?

Yes. It converts large whole numbers exactly, well beyond the range of a single byte.

Share

Try it yourself

Run your own numbers with our free tool: Binary & hex converter. No sign-up, and it works on any device.

Open the calculator