๐ข Decimal to Binary Converter with Step-by-Step Working
By Shihab Mia ยท Updated 2026-07-10
101010 Grouped in 4s: 10 1010
| Division | Quotient | Remainder (bit) |
|---|
Enter 42 and this converter returns 101010, a 6-bit binary number, using repeated division by 2: 42/2 = 21 remainder 0, 21/2 = 10 remainder 1, and so on, with the remainders read bottom to top. It shows the full working table, the number of bits, and the hexadecimal and octal forms as a bonus. Because it uses BigInt, the decimal to binary conversion stays exact even for numbers far beyond what a normal calculator can hold.
What is the Decimal to Binary Converter?
Decimal to binary conversion means rewriting a base-10 number (the digits 0 to 9 we use every day) as a base-2 number that uses only 0 and 1. Computers store everything in binary because a bit is either off (0) or on (1), so knowing how to convert decimal to binary is the first thing anyone learns in digital logic, computer science and networking. The value never changes, only the way it is written: 42 in decimal and 101010 in binary are the same quantity.
The standard hand method is repeated division by 2. You divide the decimal number by 2, write down the remainder (always 0 or 1), then divide the quotient by 2 again, and keep going until the quotient reaches 0. The binary answer is the string of remainders read from the last one back up to the first. For 42 the remainders come out 0, 1, 0, 1, 0, 1 from top to bottom, so reading bottom to top gives 101010. This tool prints that exact table so you can check your own working line by line, which is why it beats a plain answer box for homework and exam revision.
Each binary digit is a power of two, and that is the other way to see the decimal to binary conversion. Reading 101010 from the right, the place values are 1, 2, 4, 8, 16, 32. The 1s sit in the 2, 8 and 32 columns, and 2 + 8 + 32 = 42, which confirms the answer. The number of bits is simply how many place values you need: 42 needs 6 bits because 2^5 = 32 is the largest power of two that fits and 2^6 = 64 is too big.
Ordinary JavaScript numbers lose precision above 2^53, so a naive decimal to binary converter quietly returns wrong digits for large inputs. This one uses BigInt, an integer type with no size limit, so a value like 9007199254740993 converts to the correct 54-bit string instead of a rounded approximation. It also gives you the hexadecimal (base 16) and octal (base 8) forms, which are compact shorthands programmers use because each hex digit maps to exactly 4 bits and each octal digit to 3.
When to use it
- Checking homework or exam answers for a decimal to binary conversion, with the full division-by-2 table to compare against your own working.
- Computer science and digital-logic students learning how base 10 maps to base 2, and why 42 becomes 101010.
- Programmers and network engineers converting values to binary to reason about bit flags, masks and subnet math.
- Verifying that your own conversion code returns exact binary for large integers, where floating-point tools silently break.
How to use the Decimal to Binary Converter
- Type a non-negative whole number into the input box (it starts at 42 as a worked example).
- Read the binary result at the top, then use the Copy button to grab the bit string.
- Scan the step-by-step table to see each division by 2 and its remainder, read bottom to top.
- Check the bit count, and the bonus hexadecimal and octal forms, or try a preset to see a different scale.
Formula & method
Worked examples
Convert the decimal number 42 to binary by repeated division by 2.
- 42 / 2 = 21 remainder 0
- 21 / 2 = 10 remainder 1
- 10 / 2 = 5 remainder 0
- 5 / 2 = 2 remainder 1, then 2 / 2 = 1 remainder 0, then 1 / 2 = 0 remainder 1
- Read the remainders from the last division back to the first: 1, 0, 1, 0, 1, 0
Result: 42 in decimal = 101010 in binary (6 bits)
Convert 255 to binary and confirm it with place values.
- Divide repeatedly: 255/2 = 127 r1, 127/2 = 63 r1, 63/2 = 31 r1, 31/2 = 15 r1, 15/2 = 7 r1, 7/2 = 3 r1, 3/2 = 1 r1, 1/2 = 0 r1
- Every remainder is 1, so reading them gives eight 1s: 11111111
- Check with powers of two: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Result: 255 in decimal = 11111111 in binary (8 bits, one full byte)
Binary place values (powers of two)
| Bit position (k) | Power 2^k | Decimal value |
|---|---|---|
| 0 | 2^0 | 1 |
| 1 | 2^1 | 2 |
| 2 | 2^2 | 4 |
| 3 | 2^3 | 8 |
| 4 | 2^4 | 16 |
| 5 | 2^5 | 32 |
| 6 | 2^6 | 64 |
| 7 | 2^7 | 128 |
Common decimal to binary conversions
| Decimal | Binary | Bits |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 5 | 101 | 3 |
| 10 | 1010 | 4 |
| 16 | 10000 | 5 |
| 42 | 101010 | 6 |
| 100 | 1100100 | 7 |
| 255 | 11111111 | 8 |
| 256 | 100000000 | 9 |
| 1024 | 10000000000 | 11 |
Common mistakes to avoid
- Reading the remainders top to bottom. The remainders must be read from the last division (the bottom of the table) up to the first. Reading 42 top to bottom gives 010101, which is wrong. Bottom to top gives the correct 101010.
- Stopping before the quotient reaches 0. Keep dividing until the quotient is exactly 0, not until it is 1. The final step 1 / 2 = 0 remainder 1 supplies the leading bit. Stopping early drops the most significant 1 and shortens the answer.
- Trusting a converter that uses floating-point. Ordinary number types lose precision above 2^53, so many online tools return wrong binary digits for large inputs. This converter uses BigInt, so 9007199254740993 gives the exact 54-bit string, not a rounded value.
- Confusing binary with decimal digits. Binary only uses 0 and 1. Writing 42 as 42 in binary, or including a 2, is a category error. If you see any digit above 1 in a supposed binary number, the conversion is wrong.
Glossary
- Decimal (base 10)
- The everyday number system using ten digits, 0 to 9, where each place is a power of ten.
- Binary (base 2)
- A number system using only two digits, 0 and 1, where each place is a power of two. It is how computers store data.
- Bit
- A single binary digit, either 0 or 1. The bit count is how many binary digits a number needs.
- Remainder
- What is left over after a division. In the division-by-2 method the remainder is the next binary bit, always 0 or 1.
- Most significant bit
- The leftmost bit, carrying the largest place value. It comes from the last division in the method.
- BigInt
- An integer type with unlimited size, used here so decimal to binary conversion stays exact for very large numbers.
Frequently asked questions
How do you convert decimal to binary?
To convert decimal to binary, divide the number by 2 repeatedly, writing down each remainder, until the quotient is 0. Then read the remainders from last to first. For example 42 gives remainders 0, 1, 0, 1, 0, 1, which read bottom to top is 101010.
What is 42 in binary?
42 in binary is 101010, a 6-bit number. You can check it with place values: the 1s sit in the 32, 8 and 2 columns, and 32 + 8 + 2 = 42.
What is 255 in binary?
255 in binary is 11111111, which is eight 1s and exactly one byte. It is the largest value you can store in 8 bits, since 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
How many bits does a decimal number need?
A decimal number needs as many bits as the smallest power of two that exceeds it. 42 needs 6 bits because 2^5 = 32 fits but 2^6 = 64 is too big. In general the bit count is floor(log2(n)) + 1 for any n of 1 or more.
Why do the remainders get read bottom to top?
The remainders get read bottom to top because the first division produces the least significant (rightmost) bit and the last division produces the most significant (leftmost) bit. Reversing the order of remainders puts the bits in their correct place values.
Can this converter handle very large numbers exactly?
Yes. This converter uses BigInt arithmetic, which has no size limit, so even a number like 9007199254740993 converts to the exact binary string. Tools built on ordinary floating-point numbers lose precision above 2^53 and return wrong digits.