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.
1100100, which checks back as 64 + 32 + 4 = 100.Two Habits Worth Building
Check the Sum Both Ways
Say the Width Out Loud
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
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.
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.
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.
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.
| Decimal | Bits | Place values added | Fits in |
|---|---|---|---|
| 5 | 101 | 4 + 1 | 3 bits |
| 12 | 1100 | 8 + 4 | 4 bits |
| 37 | 100101 | 32 + 4 + 1 | 6 bits |
| 100 | 1100100 | 64 + 32 + 4 | 7 bits |
| 200 | 11001000 | 128 + 64 + 8 | 8 bits |
| 1000 | 1111101000 | 512 + 256 + 128 + 64 + 32 + 8 | 10 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.
No comments yet. Be the first to comment!