LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

How do you convert a decimal number (0-255) to an 8-bit binary number?

Walk the position values left to right (128 first); if the number is ≥ the value write 1 and subtract it, otherwise write 0. Example: 192 → 11000000.

You need this whenever you turn a dotted-decimal IPv4 address or a mask like 255.255.255.0 into the bit pattern a device actually uses — the basis of subnetting. The subtraction method is greedy: always take the largest position value that fits, so each decimal 0-255 produces exactly one 8-bit pattern. Gotcha: pad with leading zeros to a full 8 bits (e.g. 10 → 00001010, not 1010).

Greedy subtraction method converting 192 to binary: take 128 then 64, remainder 0, all other positions 0, giving 11000000

* Greedy subtraction: walk the weights left to right, take each that fits and subtract it, write 0 otherwise. *

Decimal to Binary Conversion (Subtraction Method):

  1. Start with position values: 128, 64, 32, 16, 8, 4, 2, 1
  2. Compare decimal to each position value (left to right)
  3. If decimal ≥ position value: write 1, subtract the value
  4. If decimal < position value: write 0, move to next position

Example: Convert 192 to binary

Value 128 64 32 16 8 4 2 1
192 ≥ 128? Yes 1
64 ≥ 64? Yes 1 1
0 ≥ 32? No 1 1 0 0 0 0 0 0

Result: 192 = 11000000

Go deeper:

From Quiz: NETW1 / Number Systems | Updated: Jul 14, 2026