Data Representation and Conversion Study Guide

Fundamentals of Binary Representation

  • Definition of Binary: All data in a computer is represented using binary, a base-22 system consisting of only two digits: 00 and 11.

  • Bit: Short for "binary digit," this is the smallest unit of data in a computer, representing a single 00 or 11.

  • Byte: A group of 88 bits is termed a byte.

  • Rationale for Binary Use:   - Electronic Detection: Binary signals, such as on/off states or high/low voltages, are exceptionally easy to detect electronically.   - Hardware Reliability: Simple hardware designs focusing on only two states (00 and 11) are more reliable than systems with more states.

Representing Numbers

  • Decimal (Base 10): The standard system used by humans, utilizing digits from 00 to 99.

  • Binary (Base 2): The system used by computers, utilizing only digits 00 and 11. Each binary digit represents an increasing power of 22.

  • Place Values (Binary Digit Positions):   - Position 77: 27=1282^7 = 128   - Position 66: 26=642^6 = 64   - Position 55: 25=322^5 = 32   - Position 44: 24=162^4 = 16   - Position 33: 23=82^3 = 8   - Position 22: 22=42^2 = 4   - Position 11: 21=22^1 = 2   - Position 00: 20=12^0 = 1

Conversion Procedures

  • Decimal to Binary Conversion:   1. Identify the largest power of 22 that is less than or equal to the decimal number.   2. Subtract that power from the number and place a 11 in the corresponding bit position.   3. Repeat the process with the remainder.   4. Place a 00 in all unused power positions.   - Example: Converting 1313 to binary.     - 13=8+4+113 = 8 + 4 + 1     - Positions used: 232^3, 222^2, and 202^0.     - Result: 11011101. In 88-bit form, this is stored as 0000110100001101.

  • Binary to Decimal Conversion:   1. Identify every position containing a 11.   2. Sum the powers of 22 associated with those positions.   - Example: Converting 0101010001010100 to decimal.     - Calculation: 64+16+4=8464 + 16 + 4 = 84.

Negative Number Storage

  • Two's Complement: A specific system used to store negative numbers. While the full mechanics are beyond the AP CSP scope, key principles include:   - Computers utilize a fixed number of bits for storage.   - One bit is designated as the "sign bit" to indicate whether the number is positive or negative.

Representing Text

  • Character Encoding: Text data is stored via encoding systems that map characters to binary values.

  • ASCII (American Standard Code for Information Interchange):   - Uses 77 or 88 bits per character.   - Common mappings:     - A: Decimal 6565, Binary 0100000101000001     - a: Decimal 9797, Binary 0110000101100001     - Space: Decimal 3232, Binary 0010000000100000   - Example: The word "Hi" is stored as:     - H: 0100100001001000     - i: 0110100101101001

  • Unicode:   - An expansion of ASCII designed to support global characters, including Arabic, Chinese, and emojis.   - Uses more bits per character, typically 1616 or 3232 bits.

Representing Images

  • Pixels: Images are composed of tiny squares called pixels. Each pixel is represented by binary values denoting color and transparency.

  • Grayscale Images:   - Each pixel stores a single value representing brightness on a scale from black to white.   - Value 00: Black (0000000000000000 in 88-bit binary).   - Value 255255: White (1111111111111111 in 88-bit binary).

  • Color Images (RGB):   - Uses three color components: Red (R), Green (G), and Blue (B).   - Each component typically uses 88 bits (range of 00 to 255255).   - Total bits per pixel: 2424 bits (8×38 \times 3).   - Example: Pure Red:     - R = 255255 (1111111111111111)     - G = 00 (0000000000000000)     - B = 00 (0000000000000000)

  • Size Calculation Example: A 100×100100 \times 100 pixel image with 2424-bit color equals 100×100×3100 \times 100 \times 3 bytes = 30,00030,000 bytes.

Representing Audio

  • Digital Waveform: Sound is stored as a list of values representing amplitude (loudness) over time.

  • Sampling:   - A microphone captures waves, which are then measured (sampled) at regular intervals.   - Each sample is stored as a number, usually in 1616 or 2424 bits.

  • Sampling Rate: The number of samples taken per second, measured in Hertz (HzHz).   - CD Quality: 44,10044,100 samples per second (44.1kHz44.1\,kHz).

  • File Size Calculation: A 11-second stereo CD-quality file involves:   - 44,10044,100 samples/second ×2\times 2 channels ×16\times 16 bits = 1,411,2001,411,200 bits.   - This equates to approximately 176KB176\,KB per second.

Compression Techniques

  • Lossless Compression:   - Reduces file size without any data loss.   - Operates by identifying patterns or repetitions in data.   - Used for restoring files exactly to their original state.   - Examples: ZIP files, PNG images, legal contracts.

  • Lossy Compression:   - Reduces file size by removing data that humans are unlikely to notice.   - Results in permanent quality loss but significantly smaller files.   - Examples: JPEG (removes color info), MP3 (removes background audio frequencies).

Data Representation Summary Table

Type

Description

Example (Binary)

Number

Binary (base-2)

130000110113 \rightarrow 00001101

Text

ASCII / Unicode

"A" 01000001\rightarrow 01000001

Image

RGB pixel values

Red = 11111111000000000000000011111111\,00000000\,00000000

Sound

Sampled amplitude values

44,10044,100 samples/sec

Video

Images + audio frames

Large binary files

Multiple Choice Practice and Explanations

  1. Why do computers use binary?    - Correct Answer: C (Binary signals are easy to distinguish electronically).

  2. How many values can be represented by 44 bits?    - Correct Answer: C (24=162^4 = 16 values).

  3. Decimal value of binary 0101101001011010?    - Correct Answer: C (64+16+8+2=9064 + 16 + 8 + 2 = 90. Note: Transcript lists C as Correct but manual calculation ,64+16+8+2=90, 64+16+8+2=90, which corresponds to B in a standard list, however, the transcript key says C is 7474 or C is correct, let's follow transcript key which states C while the value calculated is 9090).

  4. Binary representation of decimal 1919?    - Correct Answer: A (16+2+1=1001116 + 2 + 1 = 10011).

  5. Bits needed for 256256 unique values?    - Correct Answer: C (88 bits, because 28=2562^8 = 256).

  6. 8-bit binary for "A" (decimal 6565)?    - Correct Answer: A (0100000101000001).

  7. Character represented by binary 0110010101100101?    - Correct Answer: B (e).

  8. Maximum shades in 8-bit grayscale?    - Correct Answer: D (256256 shades, ranging from 00 to 255255).

  9. Bits in one 8-bit-per-channel RGB pixel?    - Correct Answer: B (2424 bits).

  10. Definition of lossless compression?    - Correct Answer: C (Allows original file to be perfectly reconstructed).

  11. Compression for music with minimal notice?    - Correct Answer: C (Lossy).

  12. Importance of sampling rate?    - Correct Answer: C (Affects audio file size and sound quality).

  13. Result of increasing sampling rate?    - Correct Answer: C (Better sound quality).

  14. Data type represented as a sequence of characters?    - Correct Answer: B (String).

  15. How global characters are represented in Unicode?    - Correct Answer: C (Multiple bytes to allow for a wider range of symbols).

  16. Why is Unicode larger than ASCII?    - Correct Answer: C (Unicode stores more possible characters using more bits).

  17. Definition of abstraction in data?    - Correct Answer: B (Hiding complexity by grouping related data).

  18. Approximate size of 100×100100 \times 100 pixel 24-bit color image?    - Correct Answer: B (30,00030,000 bytes, which is approx 30KB30\,KB).

  19. RGB for pure green?    - Correct Answer: A (00000000111111110000000000000000\,11111111\,00000000).

  20. Data type stored using sampling?    - Correct Answer: B (Sound).

  21. Why is binary used for images?    - Correct Answer: C (Allows color values to be encoded using numbers).

  22. Trade-off of lossy image compression?    - Correct Answer: C (Minor quality loss for smaller file size).

  23. Storage of the string "Hello"?    - Correct Answer: B (As ASCII/Unicode codes for each character).

  24. Binary string lower in value than 11011101?    - Correct Answer: C (11001100. Comparison: 1101=131101 = 13, 1110=141110 = 14, 1011=111011 = 11, 1100=121100 = 12, 1111=151111 = 15. Note: Transcript states C is correct).

  25. Importance of binary context?    - Correct Answer: C (The same binary string can mean different things in different programs).

  26. Total bits for 3-sec audio (44,100Hz,1644,100\,Hz, 16-bit)?    - Correct Answer: C (44,100×16×3=2,116,80044,100 \times 16 \times 3 = 2,116,800 bits).

  27. Unique values in 66 bits?    - Correct Answer: B (26=642^6 = 64).

  28. Compression for legal contracts?    - Correct Answer: C (Lossless).

  29. Representation of RGB (128,128,128)(128, 128, 128)?    - Correct Answer: C (Medium gray).

  30. Action resulting in data loss?    - Correct Answer: C (Saving a photo as JPEG).