Binary, Hex and Decimal Converter

Convert between binary, octal, decimal and hexadecimal.

Number bases

We normally count in base 10, using the digits 0 to 9. Computers use base 2 (binary, with 0 and 1) because circuits are on or off. Hexadecimal (base 16) uses the digits 0 to 9 and the letters A to F, and is a compact way to write binary: one hex digit stands for exactly four bits.

Example

Decimal 255 is 1111 1111 in binary, 377 in octal and FF in hexadecimal. You can leave out prefixes such as 0x or 0b, or include them.

By hand

To convert decimal to binary, divide by 2 repeatedly and read the remainders from last to first. To convert from binary, add up the powers of two where there is a 1: 1011 is 8 + 2 + 1 = 11.

Frequently asked questions

Why is hex used so often?

Because it is short and lines up with binary. A byte (8 bits) is always exactly two hex digits.

Can it handle negative numbers?

Yes. Put a minus sign in front. The result shows the same sign rather than a two's complement form.

Last updated