1.1.1 · D4How Computers Work

Exercises — Binary number system — conversions from - to decimal, counting in binary

2,926 words13 min readBack to topic

This page is a self-testing ladder. Each problem is stated cleanly; every solution hides inside a collapsible callout so you can forecast first, then check. The levels climb from "just recognise the pattern" up to "combine several ideas at once."

Before you start, keep the parent map in view: the Hinglish version and the source topic Binary Number System — Conversions & Counting.

Look at the picture of the weight-ruler once so the word "weight" always means a position on this ruler:

Figure — Binary number system — conversions from - to decimal, counting in binary

The purple ticks are the weights — each is double the one to its right. That doubling is the only rule you ever need for binary place-value.


Level 1 — Recognition

Goal: read a bit-pattern and name its value; recognise the weight of a position. No algorithm yet, just seeing.

L1.1

What decimal number is ?

Recall Solution L1.1

Write the weights over the bits (rightmost bit is position , weight ):

bit 1 0 1
weight

What we did: kept only the columns where the bit is . Why: a contributes nothing; a contributes its weight. So .

L1.2

In the binary number , what weight does the bit sitting third from the right carry?

Recall Solution L1.2

Positions count from the right starting at 0: the rightmost bit is position , next is , next is . "Third from the right" is position , whose weight is (The bit there happens to be , so it contributes nothing — but the weight of that slot is still .)

L1.3

Which is larger: or ? Answer by looking, not by full conversion.

Recall Solution L1.3

has its single in the highest column, weight . has s only in the three lower columns, so its biggest possible sum is . Since , is larger. Key recognition: a single high bit always beats any combination of the lower bits — because each weight is more than the sum of all smaller weights combined (). This is the doubling ruler at work.


Level 2 — Application

Goal: run each conversion algorithm end-to-end.

L2.1

Convert to decimal.

Recall Solution L2.1

Weights over the bits :

bit 1 0 1 1 0
weight

Keep the -columns (positions ): So .

L2.2

Convert to binary using repeated division by 2.

Recall Solution L2.2

Why divide by 2? The remainder of is when is odd and when even — and is the only odd-weighted column, so that remainder is exactly the last bit. The quotient drops the units column and holds the higher bits.

quotient remainder
37 18 1
18 9 0
9 4 1
4 2 0
2 1 0
1 0 1

Read remainders bottom → top: . Check: ✓ So .

L2.3

Convert to binary. (A power of two — watch what happens.)

Recall Solution L2.3

, so it should be a single followed by six s.

quotient remainder
64 32 0
32 16 0
16 8 0
8 4 0
4 2 0
2 1 0
1 0 1

Bottom → top: . Check: one in the column Every exact power of two is a lone with zeros trailing.


Level 3 — Analysis

Goal: reason about ranges, bit-counts, and structure — not just crank one conversion.

L3.1

How many bits are needed to write ? First forecast from powers of two, then verify.

Recall Solution L3.1

Forecast: and . Since , the highest weight that "fits" is , so we need 8 bits (positions through ).

Verify by division:

quotient remainder
200 100 0
100 50 0
50 25 0
25 12 1
12 6 0
6 3 0
3 1 1
1 0 1

Bottom → top: — that's 8 digitsCheck:

L3.2

A device stores numbers in 6 bits. What is the range of values it can hold, and how many distinct values is that?

Recall Solution L3.2

Each of the bits is independently or , so the number of combinations is Because counting starts at 0, the values run from up to . The largest pattern is So: 64 distinct values, range to .

L3.3

Without fully counting, decide: in a 4-bit counter running , how many times does the rightmost bit flip as you count from to , and how many times does the leftmost (weight-8) bit flip?

Recall Solution L3.3

Look at the counting figure:

Figure — Binary number system — conversions from - to decimal, counting in binary

Each column flips half as often as the column to its right, because its weight is double.

  • The rightmost bit (weight ) flips every step: from to there are steps, so it flips times. Equivalently it changes at every increment.
  • The leftmost bit (weight ) flips only when the lower three bits roll over (every steps): it goes at step . Across it flips once.

Structural read: bit at position changes state every counts, so higher bits are "lazier." That laziness is exactly why the leftmost bit tells you the biggest chunk of the value.


Level 4 — Synthesis

Goal: chain conversions with another operation, or move between bases.

L4.1

Compute in binary (increment), then convert your answer to decimal to confirm it went up by exactly one.

Recall Solution L4.1

Incrementing is the odometer move: flip the rightmost bit; if it was it becomes and carries a leftward (see Binary addition and overflow).

  • Position 0: → write , carry .
  • Position 1: → write , no carry.
  • Positions 2,3 unchanged: and . Result: . Confirm: ; . Indeed

L4.2

Convert to binary, then regroup the bits into pairs from the right — actually, regroup into groups of four from the right and give the hexadecimal digits. (Hint: 4 bits = 1 hex digit.)

Recall Solution L4.2

Step 1 — decimal to binary by division:

quotient remainder
53 26 1
26 13 0
13 6 1
6 3 0
3 1 1
1 0 1

Bottom → top: . Check:

Step 2 — group into 4s from the right. Pad the left with zeros to fill the top group: Why grouping-by-4 works: four bits carry weights , spanning values — exactly one hex digit. Each block of four converts independently.

  • hex digit 3
  • hex digit 5 So . Confirm:

L4.3

A single byte (8 bits — see Bits and Bytes) holds the pattern . What decimal number is it, and how many unused values (larger patterns) remain above it before the byte overflows?

Recall Solution L4.3

Value: weights on are . Keep the -columns (positions ): Room above: a byte's largest value is . Patterns strictly larger than number So , with 99 larger patterns before you hit the ceiling .


Level 5 — Mastery

Goal: full reasoning under a twist — degenerate inputs, or an argument, not just a number.

L5.1

Convert to binary using the division algorithm, and explain the degenerate case carefully. Then state the binary of and why it's not "empty."

Recall Solution L5.1

Run the algorithm on : we divide, get quotient and remainder , and is already , so we stop.

quotient remainder
0 0 0

The single remainder is , so . Why not empty? The value zero is a real, writable number — the convention is a single digit , just as decimal writes "0" rather than nothing. In a fixed field of bits it appears as zeros (e.g. in a byte). All zero columns means "no weight is switched on," which correctly sums to .

L5.2

Prove (by the doubling structure) that the string of ones, , equals . Then use it to instantly give the largest value of a 5-bit number.

Recall Solution L5.2

Claim: .

The string of ones sums all the weights from up to : The doubling trick: add to . The lone plus that extra makes ; that combines with the existing to make ; which combines to make ; the carry cascades all the way up until you reach a single : Picture it as an odometer of all-nines rolling over: overflows into , which is .

Apply (): the largest 5-bit value is . Check:

L5.3

Someone claims: "If I take any binary number and append a on the right, I double its value; if I append a , I get double-plus-one." Verify this on and explain why it must be true from place-value alone.

Recall Solution L5.3

Test on :

  • Append :
  • Append :

Why it must hold: appending a digit on the right shifts every existing bit one column left, and each column's weight is exactly double the column to its right. So every bit's contribution doubles → the whole value doubles. The new rightmost bit occupies the column, adding or on top. Hence "append 0 = double" and "append 1 = double plus one." (This is the binary version of "append a 0 in decimal = multiply by 10.")


Wrap-up recall

Recall What are the only two algorithms this whole page used?

Binary→decimal: sum the weights where the bit is 1. Decimal→binary: divide by 2 repeatedly, read remainders bottom-to-top.

Recall Fast identity for the largest

-bit value? (all ones), because all-ones plus one overflows to .

Connections

  • Parent topic (Hinglish) — the conversions & counting foundations these drills exercise.
  • Place-value and number bases — the engine behind every conversion here.
  • Hexadecimal and Octal — L4.2 groups bits into 4s to reach hex.
  • Bits and Bytes — L4.3 works inside an 8-bit byte (0–255).
  • Binary addition and overflow — L4.1's increment and the carry rule.
  • Two's complement — where the "" ceiling reappears for signed numbers.
  • Logic gates and switches — the two-state hardware that makes all of this base-2.