Skip to content
myAudience.
← Explore the library

Bits, hexadecimal and units encode a chosen meaning

By UK GCSE Computer Science · independent study · myAudience

Eight-bit weights 128,64,32,16,8,4,2,1 with digits 00101101 sum to 45. Extension: 255 plus 1 produces carry 1 and low eight bits zero.

Original AI-generated teaching raster via built-in image_gen; author inspected 2026-10-04. · Generated project artwork; no copied exam or publisher illustration. Independent rights/publication review pending.

Bits, hexadecimal and units encode a chosen meaning

A bit has value 0 or 1; a byte groups eight bits. An unsigned eight-bit integer ranges from 0 through 255 because eight independent bit positions encode 2 to the power 8 distinct patterns. Binary positional weights from left to right are 128,64,32,16,8,4,2,1. Entry skills are powers of two, integer division and strings. The generated binary visual gives 00101101: its active weights are 32,8,4,1, adding to 45. The same pattern could represent a character code, part of a pixel or an instruction; interpretation is supplied by a format, not by the bit pattern alone.

To convert decimal to binary, repeatedly divide by 2 and collect remainders, then reverse them, or subtract descending place values while recording whether each fits. For 45, 32 fits, 16 does not, 8 fits, 4 fits, 2 does not and 1 fits. Leading zeroes pad a specified width without changing value. Hexadecimal base 16 uses digits 0–9 and A–F, where A is ten and F is fifteen. Each hexadecimal digit corresponds to exactly four binary bits because 16=2^4. 0010 1101 becomes 2D, and 2×16+13=45. Hex is compact and easier to read, not a different value stored by the computer.

requires conversions within 0..255, ending at 11111111 and FF. Our converter rejects out-of-range values and non-integers rather than silently wrapping. Python bool is a subclass of int, so type(value) is int here intentionally rejects True as a numeric payload. Python integers have arbitrary precision, subject to available resources; an eight-bit limit is a format we enforce. Mistaking a software format for a language runtime limit would incorrectly predict overflow for an ordinary Python addition.

Lowercase b denotes bits and uppercase B bytes. Use the specification's decimal prefixes: 1 kB=1000 B, 1 MB=1000 kB, 1 GB=1000 MB, 1 TB=1000 GB. Thus 1.5 MB is 1,500,000 bytes and 12,000,000 bits. Historically some storage descriptions used kilo for 1024, but that is not this contract. Binary prefixes such as KiB are an optional distinction and must not replace the required decimal convention. A bandwidth in bits per second cannot be compared directly with a file in bytes without conversion.

The conversion algorithm and Python's format facility are separate: a built-in formatting call provides an independent check of the manually constructed string. Round-trip tests over every value 0..255 prove these implementations agree on this finite domain, while invalid-width handling needs separate tests. The transfer combines base interpretation with units and points out that a representation can satisfy one numeric range while exceeding a whole-message budget.

Runnable original Python 3 example (also saved verbatim in examples for CLI execution):
```python
def byte_binary(value):
"""Encode an integer in 0..255 as exactly eight unsigned binary digits."""
if type(value) is not int or not 0 <= value <= 255:
raise ValueError("unsigned byte required")
remaining = value
digits = []
for weight in (128, 64, 32, 16, 8, 4, 2, 1):
digit = remaining // weight
digits.append(str(digit))
remaining %= weight
return "".join(digits)

assert byte_binary(45) == "00101101"
assert int("2D", 16) == 45
for value in range(256):
assert byte_binary(value) == format(value, "08b")
assert int(byte_binary(value), 2) == value
assert 1500 * 1000 * 8 == 12_000_000
```

Worked example: Convert decimal 173 to binary and hexadecimal.

173 = 128+32+8+4+1.

The binary weights produce 10101101.

Group 1010 and 1101: A and D; 10×16+13=173.

Answer: 10101101 = AD hexadecimal.

Check your understanding: Transfer: a message contains 3000 eight-bit samples plus a 40-byte header. Can a 3 kB budget hold it? Give total bits and explain why hexadecimal display does not halve its stored size.

Answer: Total is 3040 B = 24,320 bits; 3 kB is 3000 B, so it exceeds the budget by 40 B. Hex display encodes the same sample values; a textual hex file may even use two character codes per byte before headers.

Why: Separate data representation from displayed notation. The header is part of the budget even though each individual sample fits one byte. A bit-versus-byte mismatch or an assumed 1024-based kB gives an unjustified answer.

Author source references