Data Representation Summary A1 chap 3
Number System and Representation
- Digital devices use a binary system, while people usually use a decimal system.
Units of Data
- Bit: The most basic unit of data (0 or 1).
- Byte: 1 B = 8 bits
- Kilobyte: 1 KB = 210 B = 1024 B
- Megabyte: 1 MB = 210 KB = 1024 KB
- Gigabyte: 1 GB = 210 MB = 1024 MB
- Bitrate/Data transfer rate units:
- bps: One bit per second.
- kbps: 1 kbps = 103 bps = 1000 bps
- Mbps: 1 Mbps = 103 kbps = 1000 kbps
- Gbps: 1 Gbps = 103 Mbps = 1000 Mbps
- Tbps: 1 Tbps = 103 Gbps = 1000 Gbps
Binary Numbers
- Used in data representation with digits "0" and "1".
- Conversion to Decimal: Expand the binary number by place values of powers of 2.
- Conversion from Decimal: Repeatedly divide by 2, arrange remainders from last to first, followed by the final quotient.
Calculation of Binary Numbers
- Arithmetic operations are similar to decimal numbers.
Hexadecimal Numbers
- Base-16 number system; each digit represents 4 bits (24=16).
- Digits: 0-9 and A-F (A=10, B=11, C=12, D=13, E=14, F=15).
- Conversion to Decimal: Expand the hexadecimal number by place values of powers of 16.
- Conversion from Decimal: Repeatedly divide by 16, arrange remainders (in hexadecimal) from last to first, followed by the final quotient.
Combination Lock Example
- If a combination lock has 3 digits, and each digit can be 1-9 or A-F, then total combinations = 15 × 15 × 15 = 3375.
Unsigned and Signed Integers
- Unsigned Integers: Non-negative integers (positive and zero).
- Signed Integers: Integers that can be positive, negative, or zero.
Two’s Complement Representation
- Method for representing signed integers.
- The two’s complement of X represents -X.
- Conversion to Decimal: Expand the representation using negative powers of 2 for the leftmost bit and positive powers for the rest.
- Finding Two's Complement:
- Invert all bits (one’s complement).
- Add 1 to the one’s complement.
Overflow Error
- Occurs when the result of a calculation is out of the range representable by the given number of bits.
- Unsigned Integers: Occurs during addition and subtraction when the result exceeds the maximum representable value.
- Signed Integers: Can also occur during addition and subtraction.
Character Encoding
- Systems for representing characters in digital form.
- ASCII: For English, usually uses 7 bits to represent a character.
- Chinese Encodings: Big-5 (Traditional Chinese), Guobiao (GB) code (Simplified Chinese).
- Unicode: Represents multiple languages, uses variable-width encoding (1 to 4 bytes).
Barcode
- Consists of bars and spaces of different widths representing a text string, often a product ID.
Quick Response (QR) Code
- Two-dimensional barcode made up of black dots on a white background, representing a URL, phone number, or email.
- Advantages over Barcodes: Scannable from any direction, higher error correction capability, larger character limit.
Analog vs Digital Data
- Analog Data: Continuous values (e.g., sound waves).
- Digital Data: Discrete symbols (0 and 1; e.g. text documents).
- Digitalization: Conversion of analog data to digital data through Discretisation and Quantisation.
- Files are often compressed to facilitate transmission and save storage space.
- Lossless Compression: No data lost, original file retrievable.
- Lossy Compression: Some data lost, saves more storage space.
- Compression Ratio = (Original File Size) / (Compressed File Size)
Text
- Plain Text: Stores characters only, smaller file size.
- Formatted Text: Stores characters and formatting data, larger file size.
- File Formats:
- TXT: Plain text.
- DOC/DOCX: Formatted text (Microsoft Word).
- PDF: Formatted text (cross-platform).
Image
- Bitmap Images: Stored as pixels, editable, file size = colour depth × resolution.
- Vector Images: Stored as mathematical formulae, smaller file size, do not lose quality when scaled.
- Colour depth is the number of bits used to represent the color of a pixel.
- Resolution is the total number of pixels in an image.
Audio
- Attributes: Bit depth, sampling rate, number of channels.
- File size of an uncompressed audio file: Bit depth × number of channels × sampling rate × duration.
Video
- Sequences of images (frames) shown within a duration; may contain audio.
- Frame rate: Number of frames shown per second (fps).
- File size of an uncompressed video file: color depth × resolution × frame rate × duration + size of the audio track