English:Binary, hexadecimal and digital data representation - Computing Year 9
Introduction
Convert between binary, decimal and hexadecimal, then explain how text, images and sound use declared representations. Complete the required2Fand16×8 at 4 bits/pixel calculations, run original examples, and distinguish raw payload from actual file size. Year 9 is editorial KS3 progression with GCSE preparation.
Connect binary,decimal and hexadecimal notation
One value, three ways of writing it
Binary, decimal and hexadecimal are number notations. Changing notation does not change the underlying numerical value. Binary uses two digits, decimal uses ten and hexadecimal uses sixteen. Hexadecimal extends 0 through 9 with A, B, C, D, E, F for ten through fifteen. In an unsigned byte, all eight bits together represent a value from 0 through 255. A hexadecimal digit corresponds to four bits, so two hexadecimal digits conveniently describe one byte.
For 58, the binary place values 32, 16, 8 and 2 are present. The shortest ordinary binary numeral is 111010. Writing an eight-bit field gives 00111010:0011 matches hexadecimal 3 and 1010 matches A. The leading zero bits do not change the unsigned number, although a fixed-width representation still needs its declared eight positions.
| Decimal value | Hex digit | Four-bit pattern |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
The required conversion is 2F:two groups of sixteen and another fifteen give 47. Its eight-bit form is 00101111. Do not read F as the decimal numeral 16 or write hexadecimal 2F as 2×10+F. The base determines the place values;the digit values are zero through fifteen.
Group bits without inventing data
To convert eight binary digits to hexadecimal, group from the right into sets of four. Map each group through the table. For 11001010, the groups 1100 and 1010 give CA. Conversely, CA expands to 11001010. A nibble is four bits and a byte is eight bits in this course. A single bit has two possible states;four bits have sixteen patterns, eight bits have256 patterns. These are counts of possible codes, not promises about what an application assigns them to mean.
CS50 Shorts: Hexadecimal. Pause before converting a group of four bits and check each digit against the complete original mapping table in this course. Original: CS50, Hexadecimal - CS50 Shorts. The written explanations and native tasks work without sound or the external player.
The interpretation also needs a data type or encoding. The byte value 65can be an unsigned integer;under ASCII-compatible text interpretation it can represent A. A bit pattern alone does not label itself as a number, character, pixel or instruction. Context is part of a valid explanation.
In common six-digit RGB notation, each pair supplies an eight-bit channel. For an original example,#2F80C0 means red 47, green 128, blue 192. It uses 24 channel bits before considering any file container or alpha channel. This is a representation example, not a statement that every image file stores pixels as those three uncompressed bytes.
Represent text,pixels and sampled sound carefully
Characters, code points and bytes are different
A text encoding maps character/code-point information to stored units. ASCII uses seven-bit code values for its basic range;ASCII values are commonly stored in bytes. Unicode provides a much wider set of code points. UTF-8 represents a Unicode scalar value using one to four bytes. It preserves ASCII's0 through 127 as single-byte values. Do not describe every Unicode character as one byte or as an eight-bit extension of ASCII.
| Example | Code point or points | UTF-8 bytes in hex | Number of bytes |
|---|---|---|---|
| A | U+0041 | 41 | 1 |
| £ | U+00A3 | C2 A3 | 2 |
| Rocket symbol | U+1F680 | F0 9F 9A 80 | 4 |
| Precomposed é | U+00E9 | C3 A9 | 2 |
| e with combining acute | U+0065 and U+0301 | 65 CC 81 | 3 |
The last two examples can be displayed as the same accented letter but have different code-point sequences and UTF-8 bytes. Their canonical relationship is a matter for Unicode normalisation, not a reason to count all visible letters as one byte. The course does not ask you to write a general Unicode converter;it asks you to distinguish the quantities and check the declared encoding.
Images:count pixels and bits per pixel
For a declared ideal packed raster, raw pixel bits equal width×height×bits per pixel. Bits per pixel is the total allocated code width for one pixel, not automatically the width of one colour channel. A simple4-bit indexed-pixel model provides sixteen possible index values;its palette needs separate storage if used. At8 bits per pixel, 256 codes are possible, but their meanings depend on the scheme.
For the source10×10image at 8 bits per pixel, there are 100 pixels and 800 raw bits:100 bytes when those bits pack exactly into eight-bit bytes. The required16×8image at 4 bits per pixel has128 pixels, 512 bits and 64 bytes of ideal packed pixel data. That64-byte result excludes palette, header, metadata, compression and any row-alignment requirement.
When the raw bit count is not a multiple of eight, a storage allocation needs whole bytes. In this course’s ideal model, pixel bits are packed across the complete raster without row padding. A3×3 one-bit raster has9 bits and needs 2 bytes, leaving7unused positions in the final byte. A different format that pads every row separately would instead need3 bytes. State the packing convention rather than presenting a raw formula as an exact PNG, BMP or JPEG file size.
Sound:sample count and representation depth
Uncompressed PCM payload bits follow duration×samples per second×bits per sample×channels, under the stated fixed-rate assumptions. One second at 8000 samples per second, 8 bits per sample and one channel gives 64000 bits or 8000 bytes. Two channels double that payload to 16000 bytes. These are teaching calculations, not a recording-quality recommendation or the size of every compressed audio file.
Sample rate and bit depth represent different choices:how often a signal is sampled versus how many code values represent each sample. Reducing one can lose different information from reducing the other. Headers, tags, compression and container rules remain separate. Use B for bytes and bit or b for bits consistently;do not silently interchange them.
Run conversions and verify raw-storage models
Execute original conversion and storage examples
Run the following complete Python 3 module in an approved practice environment. It operates only on small declared values and strings;it creates no image or audio file and accesses no account, network or real pupil information. The byte functions accept whole integers0 through 255 and reject Booleans. The readers accept a trimmed binary numeral of one to eight digits or a hexadecimal numeral of one or two digits, without a0b/0xprefix.
The conversion loops multiply the accumulated value by the base before adding the next digit. The binary writer divides by two repeatedly and reverses eight collected remainders. Compare its results with your manual place-value reasoning. The storage function accepts width and height1 through 4096 and a total bit depth 1 through 32 for the ideal packed model. These bounds support classroom calculations and are not a specification for every graphics format.
import re
DIGITS = "0123456789ABCDEF"
def check_byte(value):
if type(value) is not int or not (value >= 0 and 255 >= value):
raise ValueError("use a whole unsigned byte value from 0 to 255")
def byte_hex(value):
check_byte(value)
high, low = divmod(value, 16)
return DIGITS[high] + DIGITS[low]
def byte_bits(value):
check_byte(value)
bits = []
remaining = value
for unused in range(8):
remaining, bit = divmod(remaining, 2)
bits.append(str(bit))
return "".join(reversed(bits))
def read_hex(text):
if type(text) is not str or not re.fullmatch(r"[0-9A-Fa-f]{1,2}", text.strip()):
raise ValueError("use one or two hexadecimal digits, without a prefix")
total = 0
for char in text.strip().upper():
total = 16 * total + DIGITS.index(char)
return total
def read_binary(text):
if type(text) is not str or not re.fullmatch(r"[01]{1,8}", text.strip()):
raise ValueError("use one to eight binary digits")
total = 0
for char in text.strip():
total = 2 * total + int(char)
return total
def packed_bitmap(width, height, bits_per_pixel):
for name, value, limit in [("width", width, 4096),
("height", height, 4096),
("bits per pixel", bits_per_pixel, 32)]:
if type(value) is not int or not (value >= 1 and limit >= value):
raise ValueError(name + " is outside this teaching model")
bits = width * height * bits_per_pixel
packed_bytes = (bits + 7) // 8
return {"bits": bits, "packed_bytes": packed_bytes,
"unused_bits_in_last_byte": 8 * packed_bytes - bits}
if __name__ == "__main__":
for text in ["3A", "2F", "00", "FF"]:
value = read_hex(text)
print(text, value, byte_bits(value))
print(packed_bitmap(16, 8, 4))
print(packed_bitmap(3, 3, 1))
for label, text in [("ASCII A", "A"), ("pound", "£"),
("rocket", "🚀"), ("composed", "é"),
("combining", "é")]:
points = ",".join(f"U+{ord(c):04X}" for c in text)
data = text.encode("utf-8")
print(label, points, len(data), data.hex(" ").upper())The first four output lines show3A→58→00111010, 2F→47→00101111, 00→0→00000000 and FF→255→11111111. The required raster prints512 bits, 64packed bytes and 0unused final-byte bits. The3×3 one-bit case prints9 bits, 2packed bytes and 7unused bits. The text examples use Python’s actual UTF-8encoder and print the declared code points, byte lengths and bytes from the table;they do not count grapheme clusters or displayed glyphs.
Use independent checks and bounded conclusions
Check that converting any unsigned byte to hexadecimal or binary and reading it back preserves the value. A complete check across0 through 255 is feasible. Use independent built-in conversion or place-value arithmetic as a reference, not only two functions that might share the same defect. Test0, 255, one-digit hexadecimal, leading zeros, lower-case hexadecimal and invalid digits. Empty input is not automatically a byte value 0.
For storage, check units at each step. A16×8grid contains128 pixels;at 4 bits per pixel it contains512 bits;dividing by 8 gives 64 bytes. Doubling both width and height multiplies raw pixel bits by four if depth is unchanged. Doubling only the declared depth doubles raw bits without changing the number of pixels. Neither operation guarantees a particular improvement in perceived quality or a specific compressed file size.
| Original case | Raw bits | Ideal packed bytes | Important limit |
|---|---|---|---|
| 10×10 at 8 bits/pixel | 800 | 100 | Pixel payload only |
| 16×8 at 4 bits/pixel | 512 | 64 | Required calculation;palette excluded |
| 3×3 at 1 bit/pixel | 9 | 2 | Whole-raster packing, no row padding |
| One second, 8000 samples/s, 8 bits, mono | 64000 | 8000 | Uncompressed PCM payload |
| Same PCM case, two channels | 128000 | 16000 | Container and metadata excluded |
One kilobyte is 1000 bytes under decimal prefixes;one kibibyte is 1024 bytes. Identify the unit convention if you report a larger answer. The raw calculations here stop at exact bytes, so they do not need an ambiguous rounded KB label. Avoid making a precise file-size promise from an incomplete model.
Submit the required2Fconversion and 64-byte raster result, with workings and excluded overhead. Add a byte round trip, a text/code-point/byte comparison and one sound payload calculation. Explain one trade-off and one remaining assumption. A correct calculation is evidence of the declared model, not a measured media file, complete codec implementation or guarantee that the same number of visible symbols uses the same storage.
Interactive Tasks
Quiz: Test Your Knowledge
What is 2Fhexadecimal in decimal? (47) (!215) (!31) (!32)
What is 3Ahexadecimal in decimal? (58) (!310) (!48) (!60)
Which eight-bit pattern represents hexadecimal 2F? (00101111) (!00101110) (!11110010) (!00011111)
How much ideal packed pixel data is needed for 16×8 at 4 bits per pixel? (512 bits or 64bytes) (!128 bits or 16bytes) (!512bytes) (!Exactly64 bytes for every possible image file format)
What is excluded from that ideal pixel-payload result? (Palette, header, metadata, compression and row-alignment rules) (!The declared width) (!The declared height) (!The declared bits per pixel)
How many UTF-8 bytes store the pound sign U+00A3? (2) (!1because every Unicode value is ASCII) (!8because the name says UTF-8) (!Always4regardless of the code point)
Why can a displayed accented letter have different byte lengths? (Precomposed and combining code-point sequences can encode differently) (!Every glyph is always exactly one byte) (!Unicode removes all combining marks automatically) (!Hexadecimal notation changes the letter’s meaning)
What is the raw PCM payload for 1 second at 8000 samples/s, 8 bits/sample, mono? (64000 bits or 8000bytes) (!8000bits) (!64000bytes) (!The exact size of every compressed audio file)
What does a simple4-bit pixel index provide? (16possible code values before considering a palette) (!4possible values only) (!256values by definition) (!A guarantee of photorealistic colour)
Under whole-raster packing, how many bytes hold a3×3 one-bit raster? (2 with 7unused final-byte bits) (!1because each pixel is less than a byte) (!3 under every packing convention) (!9 bytes because there are nine pixels)
Memory Game
| Binary | Base-two number notation |
| Hexadecimal | Base-sixteen number notation |
| Byte | Eight bits in this course |
| Encoding | A defined mapping to stored representations |
| Bit depth | The number of bits allocated to each represented item |
| Payload | The represented data apart from container overhead |
Drag and Drop
| Hexadecimal2F | Two groups of sixteen plus fifteen give decimal47 |
| 16×8 pixels at 4 bits per pixel | Compute512 raw bits and 64ideal packed bytes |
| Pound sign in UTF-8 | Distinguish one code point from its two stored bytes |
| Two PCM channels instead of one | Double raw payload when other parameters stay fixed |
| A file header or palette | Treat it as additional to the raw pixel calculation |
Crossword Puzzle
| BINARY | Which notation uses only zero and one? |
| HEXADECIMAL | Which notation has sixteen digit values? |
| PIXEL | What is one picture element in a raster? |
| ENCODING | What defines how text or values map to stored units? |
| SAMPLING | What takes values at discrete times for sound? |
| OVERHEAD | What extra structure is omitted by a raw-payload calculation? |
LearningApps
Optional extra practice. Choose an appropriate activity with your teacher. If the external collection is unavailable, use the native activities and independent tasks in this course.
Cloze Text
Open Tasks
Easy
- Complete the required conversion: Convert2Fto decimal and show its two four-bit groups.
- Connect3Aand58: Show place values and both shortest and eight-bit binary forms.
- Calculate the required raster: Work from 16×8 at 4 bits per pixel to bits and bytes.
- Count different text quantities: Compare Aand£as code points and UTF-8 bytes.
Standard
- Run the byte conversions: Execute the full original module and reconcile0, 47, 58 and 255 with manual results.
- Check packing assumptions: Compare3×3 at 1 bit under whole-raster versus per-row byte padding.
- Calculate sampled sound: Find raw payload for the declared one-second mono case, then two channels.
- Explain file-size limits: List excluded information and why a compressed file need not equal the raw payload.
Advanced
- Verify all byte values: Design or run0..255round trips with an independent conversion reference.
- Distinguish visible letters from bytes: Use precomposed and combining examples without claiming every glyph is one code point.
- Evaluate representation trade-offs: Explain resolution, bit depth, sample rate and compression as different choices with different consequences.
- Generalise cautiously: Change width, height or depth, check exact units and state when the storage model stops describing a particular file format.
Learning Check
- Required hexadecimal conversion: Convert2Fto decimal and eight-bit binary.
- Required raster storage: Calculate16×8 at 4 bits per pixel and name omissions.
- Second conversion: Explain3Ahexadecimal as decimal and binary.
- Packing edge case: Compare whole-raster and row-padded3×3 one-bit storage.
- Text representation: Explain A,£and the two accented-letter examples.
- Sound payload and limits: Calculate the declared mono/stereo PCM cases and evaluate the claim.
Worked checks and assessment guidance
- F has digit value 15.2×16+15=47. Two four-bit groups are 0010 and 1111, giving00101111. Leading zero padding preserves the unsigned value.
- 128 pixels×4=512 bits. Ideal packed payload is 64 bytes. Palette, header, metadata, compression and row alignment are excluded;this is not a universal exact media-file size.
- 3×16+10=58. Binary place values 32+16+8+2 give 111010;an eight-bit field is 00111010. A is ten, not sixteen.
- Nine payload bits need two whole bytes with seven unused final-byte positions under this model. If each three-bit row is separately padded to one byte, three rows need three bytes. Declare which rule applies.
- A is U+0041 and UTF-8 byte 41.£ is U+00A3 and bytesC2 A3. Precomposed éuses U+00E9/bytesC3 A9;combining e+acute uses U+0065, U+0301/bytes 65 CC81. Similar display does not imply equal code-point or byte counts.
- 1×8000×8×1=64000 bits=8000 bytes. Two channels give 128000 bits=16000 bytes with other parameters fixed. Container, metadata and compression are excluded;the formula alone does not specify a codec, quality guarantee or exact compressed-file size.
Learning evidence
Keep manual hexadecimal/binary workings, the required64-byte raster calculation, packing assumptions, actual original-code outputs, an independent byte round trip, text/code-point/byte distinctions and a PCM example. State units, overhead, compression and limits instead of pretending raw payload is a measured file size.
OER and Wikipedia
Harvard CS50x: original Hexadecimal short;notation background and original publisher video. Unicode Consortium: UTF encoding FAQ and Unicode Consortium: normalisation FAQ;code-point,byte and sequence distinctions. Computer Science Field Guide: Images and Colours;representation background,not copied examples. Primary sources reviewed14November2026. All code,number examples,storage cases,questions and feedback here are original.
100 grid.PNG, The original uploader was Leightwing at English Wikiversity., Public domain. Unchanged original; caption and learning activities are original.
CodeAI: How Computers Work: Binary & Data;original supporting publisher embedding,not a partnership claim or relicensing.
Linked learning areas
aiMOOC Projects
Schulfach+


aiMOOCs


aiMOOC Projekte


MOOCwiki · Deutsch
Nach dem Lernen ist vor dem Lernen
Entdecke direkt den nächsten Lernkurs. Weitere Inhalte erscheinen, wenn Du weiter nach unten scrollst.
Zur MOOCwiki-HauptseiteMediathek
Mediathek wird aus dem Wiki geladen ...
Keine passenden Inhalte gefunden. Bitte ändere Suche oder Filter.
NEWSLernweltNOAH fragen