Binary/Hexadecimal/Decimal Converter

Free number base converter. Type a binary, octal, decimal or hexadecimal value (or any base from 2 to 36) and see all the others, plus two's complement for 8, 16, 32 and 64 bits.

✓ Runs in your browser, nothing is uploaded

Type in any box. The others update as you type. Whole numbers only; a leading minus sign, 0x, 0b and 0o prefixes, spaces and underscores are accepted.

Bits and two's complement

Enter a number above.
-Bits needed
-Unsigned value
-Signed (two's complement)
-Bytes (hex)

How to use the number base converter

Click into any of the boxes and type a number in that base. Binary uses the digits 0 and 1, octal uses 0 to 7, decimal is the everyday system, and hexadecimal adds the letters A to F for the values 10 to 15. Every other box updates immediately, so you can see the same value written four ways.

The bits panel shows the value as a row of binary digits in groups of four, which makes long values easier to read, and shows how the same bits are read as an unsigned or a signed number at the width you pick. Use it to check bit masks, memory addresses, register values and microcontroller settings.

Binary/Hexadecimal/Decimal Converter: a complete guide

Number bases in a nutshell

A number base, or radix, is how many different digits a counting system uses before it needs a new column. We normally count in base 10, with ten digits from 0 to 9. Computers store everything as on and off signals, so they work in base 2, called binary, which has only the digits 0 and 1.

Long binary strings are hard to read, so engineers and programmers also use base 16, called hexadecimal, where one hex digit stands for exactly four bits, and base 8, called octal, where one digit stands for three bits. Hex uses the digits 0 to 9 and the letters A to F for the values 10 to 15.

Converting by hand

To convert binary to decimal, give each digit a weight that doubles as you move left: 1, 2, 4, 8, 16 and so on. Add the weights where there is a 1. For 1101, that is 8 + 4 + 0 + 1, which is 13.

To convert decimal to binary, divide by 2 repeatedly and note the remainders, then read them from last to first. For 13: 13 divided by 2 is 6 remainder 1, 6 divided by 2 is 3 remainder 0, 3 divided by 2 is 1 remainder 1, and 1 divided by 2 is 0 remainder 1. Reading upwards gives 1101.

To go between binary and hex, group the bits in fours from the right. 1111 0101 is F5, because 1111 is F and 0101 is 5. The converter does all of this at once and also handles any base from 2 to 36.

Where you will meet these numbers

  • Memory addresses and machine code are written in hex, for example 0x7FFF.
  • Colour codes on the web, such as #FF8800, are three hex bytes for red, green and blue.
  • Bit masks and flags in embedded programming, where each bit switches one feature on or off.
  • Network work: IPv6 addresses are hex, and an IPv4 subnet mask such as 255.255.255.0 is easier to understand in binary.
  • Digital electronics, PLC addresses and microcontroller registers.
  • Permissions on Linux files are octal, where 755 and 644 are three octal digits.

Two's complement and negative numbers

Plain binary has no minus sign, so computers use two's complement to store negative whole numbers. The bits are the same, but the leftmost bit is given a negative weight. In an 8-bit number, the leftmost bit is worth -128, so 10000000 is -128 and 11111111 is -1.

To write a negative number such as -5 in 8 bits, take the positive value 00000101, flip every bit to get 11111010, and add 1 to get 11111011. The bits panel does this for you at 8, 16, 32 and 64 bits, and shows the unsigned and signed readings side by side. The same pattern of bits can mean 251 or -5 depending on whether it is read as unsigned or signed, which is a classic source of bugs.

Useful reference values

  • 255 is FF in hex and 11111111 in binary, the largest 8-bit unsigned value.
  • 256 is 100 in hex, and 1024 is 400 in hex.
  • 65535 is FFFF, the largest 16-bit unsigned value.
  • 127 is the largest signed 8-bit value, and -128 is the smallest.
  • 2147483647 is 7FFFFFFF, the largest signed 32-bit value.

Frequently asked questions

How do I convert binary to decimal?

Type the binary number in the Binary box and the decimal value appears at once. By hand, multiply each digit by a power of 2, starting from 1 on the right, and add them up: 1011 is 8 + 0 + 2 + 1, which is 11.

How do I convert hexadecimal to decimal?

Type the value in the Hexadecimal box. Hex uses the digits 0 to 9 and the letters A to F for 10 to 15, so 1F is 1 x 16 + 15, which is 31. A prefix such as 0x is accepted.

What is two's complement?

It is the way computers store negative whole numbers. The leftmost bit is the sign bit, and a negative value is written as the number you get by counting back from 2 to the power of the bit width. In 8 bits, -1 is 11111111 and -128 is 10000000.

Can it handle very large numbers?

Yes. The converter uses arbitrary-precision integers, so a 64-bit or even a 200-digit value converts exactly with no rounding.

Does it convert fractions such as 0.5?

No. This tool converts whole numbers, which covers addresses, bit masks, colour codes and register values. Decimal points are rejected with a clear message.

Which other bases are supported?

The custom base box accepts any base from 2 to 36, using digits 0 to 9 and letters A to Z. Base 32 and base 36 are common for compact identifiers.

More tools you may like