Data Representation and Conversion Study Guide
Fundamentals of Binary Representation
Definition of Binary: All data in a computer is represented using binary, a base- system consisting of only two digits: and .
Bit: Short for "binary digit," this is the smallest unit of data in a computer, representing a single or .
Byte: A group of 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 ( and ) are more reliable than systems with more states.
Representing Numbers
Decimal (Base 10): The standard system used by humans, utilizing digits from to .
Binary (Base 2): The system used by computers, utilizing only digits and . Each binary digit represents an increasing power of .
Place Values (Binary Digit Positions): - Position : - Position : - Position : - Position : - Position : - Position : - Position : - Position :
Conversion Procedures
Decimal to Binary Conversion: 1. Identify the largest power of that is less than or equal to the decimal number. 2. Subtract that power from the number and place a in the corresponding bit position. 3. Repeat the process with the remainder. 4. Place a in all unused power positions. - Example: Converting to binary. - - Positions used: , , and . - Result: . In -bit form, this is stored as .
Binary to Decimal Conversion: 1. Identify every position containing a . 2. Sum the powers of associated with those positions. - Example: Converting to decimal. - Calculation: .
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 or bits per character. - Common mappings: - A: Decimal , Binary - a: Decimal , Binary - Space: Decimal , Binary - Example: The word "Hi" is stored as: - H: - i:
Unicode: - An expansion of ASCII designed to support global characters, including Arabic, Chinese, and emojis. - Uses more bits per character, typically or 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 : Black ( in -bit binary). - Value : White ( in -bit binary).
Color Images (RGB): - Uses three color components: Red (R), Green (G), and Blue (B). - Each component typically uses bits (range of to ). - Total bits per pixel: bits (). - Example: Pure Red: - R = () - G = () - B = ()
Size Calculation Example: A pixel image with -bit color equals bytes = 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 or bits.
Sampling Rate: The number of samples taken per second, measured in Hertz (). - CD Quality: samples per second ().
File Size Calculation: A -second stereo CD-quality file involves: - samples/second channels bits = bits. - This equates to approximately 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) | |
Text | ASCII / Unicode | "A" |
Image | RGB pixel values | Red = |
Sound | Sampled amplitude values | samples/sec |
Video | Images + audio frames | Large binary files |
Multiple Choice Practice and Explanations
Why do computers use binary? - Correct Answer: C (Binary signals are easy to distinguish electronically).
How many values can be represented by bits? - Correct Answer: C ( values).
Decimal value of binary ? - Correct Answer: C (. Note: Transcript lists C as Correct but manual calculation , which corresponds to B in a standard list, however, the transcript key says C is or C is correct, let's follow transcript key which states C while the value calculated is ).
Binary representation of decimal ? - Correct Answer: A ().
Bits needed for unique values? - Correct Answer: C ( bits, because ).
8-bit binary for "A" (decimal )? - Correct Answer: A ().
Character represented by binary ? - Correct Answer: B (e).
Maximum shades in 8-bit grayscale? - Correct Answer: D ( shades, ranging from to ).
Bits in one 8-bit-per-channel RGB pixel? - Correct Answer: B ( bits).
Definition of lossless compression? - Correct Answer: C (Allows original file to be perfectly reconstructed).
Compression for music with minimal notice? - Correct Answer: C (Lossy).
Importance of sampling rate? - Correct Answer: C (Affects audio file size and sound quality).
Result of increasing sampling rate? - Correct Answer: C (Better sound quality).
Data type represented as a sequence of characters? - Correct Answer: B (String).
How global characters are represented in Unicode? - Correct Answer: C (Multiple bytes to allow for a wider range of symbols).
Why is Unicode larger than ASCII? - Correct Answer: C (Unicode stores more possible characters using more bits).
Definition of abstraction in data? - Correct Answer: B (Hiding complexity by grouping related data).
Approximate size of pixel 24-bit color image? - Correct Answer: B ( bytes, which is approx ).
RGB for pure green? - Correct Answer: A ().
Data type stored using sampling? - Correct Answer: B (Sound).
Why is binary used for images? - Correct Answer: C (Allows color values to be encoded using numbers).
Trade-off of lossy image compression? - Correct Answer: C (Minor quality loss for smaller file size).
Storage of the string "Hello"? - Correct Answer: B (As ASCII/Unicode codes for each character).
Binary string lower in value than ? - Correct Answer: C (. Comparison: , , , , . Note: Transcript states C is correct).
Importance of binary context? - Correct Answer: C (The same binary string can mean different things in different programs).
Total bits for 3-sec audio (-bit)? - Correct Answer: C ( bits).
Unique values in bits? - Correct Answer: B ().
Compression for legal contracts? - Correct Answer: C (Lossless).
Representation of RGB ? - Correct Answer: C (Medium gray).
Action resulting in data loss? - Correct Answer: C (Saving a photo as JPEG).