Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
Decimal to Binary

Decimal to Binary

A place-value check for digital-logic homework: enter a whole number, read the bit pattern in nibble columns and confirm the width it needs.

Writing a Decimal Number in Powers of Two

Half of a digital-logic course happens in base-2: truth tables, ripple-carry adders, counters that roll over, register widths that decide how big a value can get. Every one of those exercises starts by rewriting an ordinary number as a row of bits. Do that by hand, then check yourself here before the answer goes on the worksheet.

Divide by two and keep the remainders: read them bottom to top. For 100 the remainders come out as 1100100, which checks back as 64 + 32 + 4 = 100.

Two Habits Worth Building

Check the Sum Both Ways

Add the place values of the ones in your answer. If the total is not the number you started with, a remainder went in the wrong order.

Say the Width Out Loud

An exam answer is usually a fixed-width word. Count the bits you got, then pad on the left to four, eight or sixteen positions.

Once the pattern is in front of you, the rest of the coursework follows: line two patterns up to practise binary addition, flip every bit for a one's complement, or point at the bit that a shift instruction would push off the end.

Checking Your Homework Answer

1

Enter the whole number

The upper field takes digits 0 to 9 and nothing else. There is no decimal point and no minus sign, because a fraction or a signed value needs a format decision the tool cannot make for you.

2

Compare bit by bit

The pattern below is shown in groups of four, which lines up with the nibble columns most textbooks use for their worked solutions.

3

Copy without the spacing

The copy button returns the bits joined up and prefixed with 0b, so a value can go straight into a simulator or a Python expression.

Marking the reverse question: type a bit pattern into the lower field and its value appears above. The swap button hands the pattern to the binary-first page if you would rather work there.

Place Values, Bit Widths and Homework Checks

These six values cover most of what a first-year exercise sheet asks for. The third column shows the sum you should get when you add the place values back up, and the fourth is the narrowest register that still holds the number.

DecimalBitsPlace values addedFits in
51014 + 13 bits
1211008 + 44 bits
3710010132 + 4 + 16 bits
100110010064 + 32 + 47 bits
20011001000128 + 64 + 88 bits
10001111101000512 + 256 + 128 + 64 + 32 + 810 bits

Nibble Columns for Marking

Groups of four make it quick to compare your handwritten answer against the screen one column at a time.

Answers Update Per Keystroke

Step a counter through 6, 7, 8 and watch the carry ripple into a new column — useful when explaining overflow to a study group.

Big Values Stay Precise

Numbers beyond fifteen digits are handled with big-integer arithmetic, so a 64-bit limit such as 18446744073709551615 converts exactly.

Coursework Questions About Base-2

How do I write a negative value in binary?

Pick the width first, convert the size of the number, invert every bit and add one. For −5 in eight bits, start from 00000101 and you finish at 11111011. The width matters, which is why the tool asks for whole positive values only.

How many bits will my number need?

Count the digits in the answer — that is the minimum width. A useful checkpoint: n bits reach 2ⁿ − 1, so 8 bits stop at 255 and 16 bits stop at 65535.

Which end of the pattern is the least significant bit?

The rightmost one, worth 1, is bit 0. Numbering climbs to the left, so in 1100100 the highest set bit is bit 6, worth 64.

Why does an odd number always end in 1?

Every place value except the last is a multiple of two, so only bit 0 can contribute an odd amount. That single bit is what a parity check or an even/odd test looks at.

Can I use this to practise binary addition?

Convert both operands, add them on paper with carries, then convert the decimal sum here and compare the two patterns. Any mismatch points straight at the column where the carry went astray.

0123456789
01
0b

Worked Homework Values

5 = 101
12 = 1100
37 = 100101
100 = 1100100
200 = 11001000
1000 = 1111101000

Decimal (Base-10)

The side of the exercise you are given: an ordinary whole number, no point and no sign.

Binary (Base-2)

The side you must produce: a row of place values doubling to the left, ready to pad out to a register width.

Add the place values back up to check your own answer
100 = 1100100, that is 64 + 32 + 4
Pad on the left yourself to reach a 4, 8 or 16-bit width
The copy button returns the bits joined and prefixed with 0b
Want to learn more? Read documentation →
1/5
Start typing to search...
Searching...
No results found
Try searching with different keywords