Data Representation and Computer Codes
Preview Part C: Data and Logic · Chapter 12 · 13 min read · 54 practice questions
After this chapter you will be able to
- explain how text, numbers, images and sound are stored as bits
- describe BCD, Excess-3 and Gray codes with examples
- compare ASCII, EBCDIC and Unicode
- explain parity bits and simple error detection
Chapter 12 at a glance Recall: BCD = 4 bits per digit · Gray = one bit changes · ASCII 7-bit, EBCDIC 8-bit · parity detects, Hamming corrects.
12.1 Everything Becomes Bits
| Numbers |
Binary integers (2’s complement for negatives); floating-point for decimals (IEEE 754: sign, exponent, mantissa) |
| Text |
Each character gets a number from a character code (ASCII, Unicode) |
| Images |
A grid of pixels; each pixel stores colour bits (e.g., 24-bit RGB) — bitmap/raster; or shapes as maths — vector |
| Sound |
Sound wave is sampled thousands of times per second (e.g., 44.1 kHz for CD) and each sample stored as bits |
| Video |
A sequence of image frames (e.g., 30 frames per second) plus sound |
- Analog-to-digital conversion (ADC) changes real-world signals into bits; DAC changes them back.
- Compression makes files smaller: lossless (ZIP, PNG, FLAC — no data lost) vs lossy (JPEG, MP3, MP4 — some detail removed).
- Colour depth: a 1-bit image is black and white; an 8-bit image can show 256 colours.
- CD-quality audio: 44.1 kHz sampling, 16 bits per sample, stereo — about 1.41 Mbps.
- Bit depth (sample size or audio resolution) is the number of bits stored for each audio sample. More bits give finer amplitude detail.
- Multimedia combines several media types — text, graphics, sound, video and animation — in one presentation or application.
- To code N different items you need the smallest n with 2ⁿ ≥ N. For example, 64 items need 6 bits, 256 need 8, 512 need 9 and 1024 need 10.
⚡ QUICK FACT — A bitmap image becomes blocky (pixelated) when enlarged; a vector image (SVG, AI files) stays sharp at any size.
| GIF |
Graphics Interchange Format |
8-bit, up to 256 colours from a palette |
Lossless (LZW) |
Simple graphics, logos and small animation |
| PNG |
Portable Network Graphics |
24-bit true colour (about 16.7 million colours) |
Lossless |
Supports transparency (alpha channel) |
| JPEG |
Joint Photographic Experts Group |
24-bit colour |
Lossy |
Photographs |
| BMP |
Bitmap |
Various |
Usually uncompressed |
Windows bitmap format |
12.2 Units of Data
| Bit |
0 or 1 |
| Nibble |
4 bits |
| Byte |
8 bits (one character in ASCII) |
| Word |
16/32/64 bits (depends on the CPU) |
| Double word |
32 bits |
What the full chapter covers
The full chapter has these sections:
- 12.1 Everything Becomes Bits
- 12.2 Units of Data
- 12.3 Numeric Codes
- 12.4 Character Codes
- 12.5 Error Detection: Parity
- 12.6 Floating-Point Representation (Idea)
- 12.7 Two More Numeric Codes
- 12.8 Worked Examples
- 12.9 More Exam Facts
- Chapter Quick Revision
- Most Important Terms
- Common Confusions
- Rapid Recall
Sample questions from this chapter
1. Unicode encoding that always uses 4 bytes?
- UTF-32
- ISCII
- EBCDIC
- UTF-8
Show answer
Answer: A. UTF-32
UTF-32 uses a fixed 4 bytes for every character.
2. Binary of Gray code 11010011?
- 11010011
- 10011100
- 10111010
- 10011101
Show answer
Answer: D. 10011101
Gray to binary: the first bit stays; each next binary bit = previous binary bit XOR the Gray bit, giving 10011101.
3. Storage size of one ASCII character?
- 4 bits (1 nibble)
- 8 bits (1 byte)
- 16 bits (2 bytes)
- 7 bits
Show answer
Answer: B. 8 bits (1 byte)
Each ASCII character is stored in one byte (8 bits), though the standard code uses 7 bits.
4. Bits needed to code 64 items?
- 5
- 8
- 7
- 6
Show answer
Answer: D. 6
With n bits you get 2ⁿ codes; 2⁶ = 64, so 6 bits are needed.
5. Term for the number of bits in an audio sample?
- Bit depth
- Sampling rate
- Bit rate
- Frame rate
Show answer
Answer: A. Bit depth
Bit depth is the number of bits used to store each audio sample; more bits give finer detail.