Notes
Binary and hexadecimal
- Binary is base 2. Place values are 1, 2, 4, 8, 16, 32, 64, 128. Add the place values that have a 1 to convert to decimal.
- With n bits there are 2 to the power n values. 8 bits give 256 values (0 to 255).
- Hexadecimal is base 16 (0-9, A-F). One hex digit equals 4 bits. Binary addition: 1+1=10.
Text, images and sound
- ASCII maps characters to numbers ('A' = 65, 'a' = 97). Unicode covers many languages and emoji.
- An image is a grid of pixels; 24-bit RGB color uses 3 bytes per pixel. Sound is sampled many times per second.
- File size grows with resolution, bits per pixel, sample rate and length.
Compression
- Lossless compression is fully reversible (ZIP, PNG). Lossy removes some data for smaller files (JPEG, MP3).
- Run-length encoding stores counts for repeats: "AAAB" becomes "3A1B".
Topics in this unit
Each topic has its own short notes and practice.
Practice
8 + 2 = 10.
2 x 2 x 2 x 2 = 16 values (0 to 15).
C is 12, which is 8 + 4 = 1100.
a=97, b=98, c=99.
100 x 50 = 5,000 pixels, times 3 bytes = 15,000 bytes.
Permanently removing data to save space is lossy compression.
Free response
Write your answer first, then open the scoring guide.
Free-response question
A game designer stores data for a small game.
(a) Convert the binary number 100101 to decimal. Show the place values you used.
Show the answer and scoring guide
32 + 4 + 1 = 37.
Check off the points you earned:
(b) A black-and-white sprite is 8 pixels wide and 8 pixels tall with 1 bit per pixel. How many bits and how many bytes does it need?
Show the answer and scoring guide
8 x 8 = 64 pixels, so 64 bits. 64 divided by 8 = 8 bytes.
Check off the points you earned:
(c) The designer compresses the game's text with run-length encoding. Encode "AAAAABBC" and say whether this compression is lossless or lossy.
Show the answer and scoring guide
The encoding is "5A2B1C". Run-length encoding is lossless because the original can be rebuilt exactly.
Check off the points you earned: