Number Base Converter
Binary, decimal, hexadecimal and octal, with the working written out.
Formulas
- Place value a number in base b is the sum of each digit × b to the power of its place, counting places from 0 on the right
- Hex digits A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
Worked example
Convert 45 to binary and to hexadecimal.
- Divide by 2 and keep the remainders: 45 → 22 r 1, 22 → 11 r 0, 11 → 5 r 1, 5 → 2 r 1, 2 → 1 r 0, 1 → 0 r 1.
- Read the remainders from the bottom up: 101101.
- Check: 32 + 8 + 4 + 1 = 45.
- For hex, 45 = 2 × 16 + 13, and 13 is D.
Answer: 45 = 101101 in binary and 2D in hexadecimal.
Common mistakes
- Reading the remainders from the top down, which writes the binary number backwards.
- Counting place values from 1 instead of 0: the rightmost digit is worth b⁰ = 1.
- Writing 10 to 15 as two digits in hex instead of A to F.
- Dropping leading zeros when a fixed width is asked for, such as 8 bits: 45 is 00101101.
About this tool
This converter turns a whole number into binary, octal, decimal and hexadecimal at once, and into any base from 2 to 36 if you need one. It writes out the working the way a GCSE or A-level Computer Science answer expects: place values to get into decimal, repeated division to get out of it, and groups of four bits for hex. It also shows how the number sits in 8, 16, 32 or 64 bits, including two's complement for negative numbers.
Tips
- Each hex digit is exactly four bits, so binary to hex never needs decimal in between: split into fours from the right and convert each group.
- If an 8-bit answer starts with 1, it means something different as a signed number. The In bits section shows both readings.
- Check your own working by typing your answer back in with its base: the decimal line should match where you started.
FAQ
- How do I convert binary to decimal?
- Write the place values over the bits, starting with 1 on the right and doubling each time to the left. Add the place values that have a 1 under them. 101101 is 32 + 8 + 4 + 1 = 45. The working section lays this out for any number you type.
- How do I convert decimal to binary?
- Divide by 2 and write down the remainder, then divide the answer by 2 again, until you reach 0. The remainders read from the bottom up are the binary number. The converter shows every division.
- What is two's complement?
- It is how computers store negative whole numbers. To find it, write the positive number in binary, flip every bit, then add 1. In 8 bits, -1 is 11111111 and -128 is 10000000.
- Why does my number say it is too big for 8 bits?
- An unsigned 8-bit number can only go up to 255, because 8 bits give 256 patterns. Anything larger needs more bits, and in a program it would overflow. The converter tells you how many bits the number really needs.
- Does it handle very large numbers?
- Yes. It works with whole numbers of up to 300 digits exactly, with no rounding. For very long numbers it gives the answer without writing out every step.