Number Base Converter
Convert a whole number between decimal, hexadecimal, binary and octal. The arithmetic is done on the digits rather than on a floating-point value, so wide numbers such as 64-bit integers stay exact, and every base is shown at once.
Converted digit by digit, so the value never passes through a floating-point number and 64-bit inputs stay exact.
Formula and calculation
Worked example
Converting 255 to hexadecimal divides by 16 and collects the remainders: 255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15, and 15 is F, so the answer is FF. The same value in the other bases is 11111111 in binary, 377 in octal and 255 in decimal.
Signed numbers, bit width and two's complement
A leading minus sign is kept and put back on the result, so -255 in hex is -FF. Computers store negative integers differently, as two's complement, where the top bit carries the sign: a signed byte holds -128 to 127 while an unsigned byte holds 0 to 255. That is why the bit-width line matters — a value that fits one width may overflow another. Hexadecimal and octal survive contact with hardware because both bases are powers of two: one hex digit is exactly four bits and one octal digit exactly three, so neither ever needs rounding.
What the results mean
- 255 dec =
- The number written in the base chosen in To, using that base's digits (hexadecimal uses A to F for the values 10 to 15).
- Binary (base 2)
- The same number in binary (base 2), the representation a computer stores it in.
- Octal (base 8)
- The same number in octal (base 8), where one digit carries exactly three bits.
- Decimal (base 10)
- The same number in decimal (base 10), the everyday reading of the value.
- Hexadecimal (base 16)
- The same number in hexadecimal (base 16), where two digits make exactly one byte.
- Bit width
- How many bits the value needs and the standard integer size it fits into, which tells you whether it overflows a byte, a 16-bit word or a 32-bit integer.
Frequently asked questions
How do I convert decimal to binary by hand?
Divide by 2 repeatedly and collect the remainders, then read them in reverse: 255 divides into 128, 64, 32, 16, 8, 4, 2 and 1 with remainder 1 every time, so it is 11111111. The steps table under the result lays out the same division.
What does 0x mean in front of a number?
It marks the number as hexadecimal, so 0xFF is 255 in decimal. This converter recognizes 0x for hex, 0b for binary and 0o for octal; a prefix in the value overrides the From base, which is how most programming languages write these literals.
How many bits are in a hexadecimal digit?
Exactly four, which is why hex is used for memory dumps, byte values and color codes: two hex digits make one byte and eight make a 32-bit word. An octal digit carries exactly three bits, so it groups binary digits in threes instead of fours.
Why is FF equal to 255?
Because each digit is weighted by a power of 16 and F stands for 15: FF means 15 × 16 + 15 = 255. The conversion here runs on the digits themselves, so a 64-bit value such as FFFFFFFFFFFFFFFF comes out as 18446744073709551615 with no rounding.