Number Base Converter

Convert numbers between binary, octal, decimal and hexadecimal in any direction, with all four bases and the bit count shown at once.

Result

Converted number

11111111

Binary (base 2)
11111111
Octal (base 8)
377
Decimal (base 10)
255
Hexadecimal (base 16)
FF
Bits needed
8bits

Type a whole number, choose the base it is written in and the base you want: the converter shows the result and the same number in binary, octal, decimal and hexadecimal, plus how many bits it needs. It reads the number exactly, with no rounding, so long values such as 32-bit or 64-bit masks convert correctly.

Formula

Value = Σ digitᵢ × baseⁱ (positions counted from the right, starting at 0). To write it in another base, divide repeatedly by the new base and read the remainders from last to first.

How it works

Type a whole number in the base you choose: digits 0 and 1 for binary, 0 to 7 for octal, 0 to 9 for decimal and 0 to 9 plus A to F for hexadecimal. Spaces are ignored, so long binary numbers can be typed in groups of four (1111 0000). Do not add 0x or 0b prefixes; pick the base in the list instead. The number is read exactly with big integers, so there is no rounding, and the result is shown in all four bases plus the number of bits it needs.

How to convert between bases step by step

In a positional system each digit is multiplied by a power of the base. To go from any base to decimal, multiply each digit by base to the power of its position (counting from 0 at the right) and add. Binary 101010 is 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42. Hex 1A3F is 1×4096 + 10×256 + 3×16 + 15 = 6,719.

To go from decimal to another base, divide by the new base repeatedly and write the remainders from last to first. 42 ÷ 2 gives remainders 0, 1, 0, 1, 0, 1, so 42 is 101010 in binary. Between binary and hex there is a shortcut: each group of 4 bits is one hex digit (1010 1010 = AA), and each group of 3 bits is one octal digit.

Worked example: 255 in binary, octal and hex

Enter 255, choose decimal as the starting base and binary as the target. The result is 11111111: eight ones, the largest value a single byte can hold. The other results show 377 in octal and FF in hexadecimal, and the bit count is 8.

Going back, type FF with hexadecimal as the starting base and you get 255 in decimal and 11111111 in binary. For long binary numbers you can type spaces between groups (1111 1111 1111 1111); the converter ignores them and gives FFFF, or 65,535.

Quick table: values worth knowing

Decimal to binary and hex: 42 = 101010 = 2A, 255 = 11111111 = FF, 1,000 = 1111101000 = 3E8, 65,535 = 1111111111111111 = FFFF, 2,147,483,647 = 7FFFFFFF (the largest signed 32-bit integer).

Octal and permissions: 777 octal = 511 decimal, and the Unix permission 644 is 110 100 100 in binary (read and write for the owner, read for everyone else), which is 420 in decimal.

Where each base is used

Binary is how computers store everything, but it gets long fast, so programmers write the same bits in hexadecimal: two hex digits per byte. Colors on the web (#FF8800), memory addresses, MAC addresses and hashes are all hex. Octal survives mainly in Unix file permissions.

Bytes and their multiples are covered by the data storage converter, and for numbers written with letters in a different sense, the Roman numeral converter turns numbers like 2026 into MMXXVI.

Common mistakes and tips

Type only the digits valid for the chosen base: 0 and 1 for binary, 0 to 7 for octal, 0 to 9 and A to F for hex. Do not add prefixes like 0x or 0b; choose the base in the list instead. An invalid digit, such as 2 in a binary number, returns no result.

This converter works with whole numbers. Negative numbers are shown with a minus sign, not in two's complement; to get the two's complement of a negative value in n bits, add 2ⁿ to it first (for 8 bits, -1 becomes 255, or 11111111).

Frequently Asked Questions

What is 255 in binary and hex?
255 is 11111111 in binary (eight ones, the largest value of one byte) and FF in hexadecimal.
How do I convert binary to decimal?
Multiply each bit by 2 raised to its position from the right (starting at 0) and add. 1101 is 8 + 4 + 0 + 1 = 13.
What is 1,000 in hexadecimal?
1,000 in decimal is 3E8 in hex (3×256 + 14×16 + 8).
Why do programmers use hexadecimal?
Because one hex digit is exactly 4 bits, so a byte is always two hex digits. It is much shorter than binary and converts to it digit by digit.
How many bits does a number need?
The number of digits in its binary form. 255 needs 8 bits, 256 needs 9. The converter shows this count for every number.