Overview

Hexadecimal, or base 16, uses the digits 0–9 and A–F. It is common in programming, web colors and memory addresses. This converts a whole decimal number to hex, binary and octal.

Enter a non-negative whole number.

Worked examples

InputsResult
Decimal number255Hexadecimal: FFBinary: 11111111Octal: 377
Show 2 more examples
Decimal number4,096Hexadecimal: 1000Binary: 1000000000000Octal: 10000
Decimal number16Hexadecimal: 10Binary: 10000Octal: 20

How it works

Divide by 16 repeatedly, and read the remainders from last to first. Each hex digit stands for exactly four binary digits, which is why programmers use it as shorthand for binary. For example, FF is 11111111.

The formula

Decimal = Σ digit × 16^position
positionStarts at 0 from the rightmost digit

Practical tips

  • 255 is FF in hex, 11111111 in binary and 377 in octal.
  • Web colors use two hex digits per channel, such as #FF0000 for red.
  • Hex A–F stand for 10–15.

Frequently asked questions

Why is hex used in computing?

It is much shorter than binary and converts to it directly, four bits per digit.

What is the 0x prefix?

A marker many programming languages use for hex numbers, as in 0xFF.