Units and Data Representation
This section provides an overview of units and data representation concepts in Computer Science, covering the basics of data measurement, conversions, and multimedia file properties. Understanding these concepts helps explain how computers interpret, store, and transmit data.
Units: Analogue Data and Digital Data
Analogue Data: Represents data in a continuous form, like sound waves or light. Analogue signals vary continuously and are not limited to discrete values. Examples include sound waves, temperature, and radio signals.
Digital Data: Represents data in discrete binary form (0s and 1s). Digital data is used by computers because it is easier to store, process, and transmit accurately in binary.
Data Capacity
Definition: Data capacity refers to the amount of data a storage medium can hold, typically measured in bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB), and terabytes (TB). Each level represents a power of 1024 (e.g., 1 KB = 1024 bytes).
Importance: Understanding data capacity helps in estimating storage needs for files and applications, ensuring suitable memory and storage allocation.
Binary and Denary
Binary (Base-2): A numbering system that uses only two digits, 0 and 1. Each binary digit (bit) represents an increasing power of 2, starting from the right.
Denary (Base-10): The standard numbering system we use daily, with digits from 0 to 9. Each position represents an increasing power of 10.
Binary to Denary Conversion
To convert binary to denary, multiply each binary digit by its positional power of 2 and add the results.
Example: Binary 1101 converts to denary by calculating
1
×
8
+
1
×
4
+
0
×
2
+
1
×
1
=
13
1×8+1×4+0×2+1×1=13.
Denary to Binary Conversion
To convert denary to binary, repeatedly divide the number by 2, recording the remainders until the quotient is zero, then read the remainders from bottom to top.
Example: Denary 13 converts to binary by performing division:
13
→
1101
13→1101.
Binary Addition and Overflow
Binary Addition: Performed similarly to decimal addition but using only 0s and 1s. If a sum is greater than 1, the extra value is carried to the next position.
Overflow: Occurs when the result of a binary addition exceeds the available bit length, causing a "wrap-around" error. Overflow is particularly problematic in limited-bit systems like 8-bit registers.
Hexadecimal
Definition: A base-16 numbering system using digits 0-9 and letters A-F. Each hex digit represents four binary digits (bits), making it useful for simplifying binary.
Hexadecimal to Denary Conversion: Multiply each hex digit by 16 raised to its position’s power.
Denary to Hexadecimal Conversion: Repeatedly divide the number by 16, recording remainders.
Binary to Hexadecimal Conversion: Group binary digits in sets of four (from right) and convert each group to a hex digit.
Hexadecimal to Binary Conversion: Convert each hex digit to a four-bit binary equivalent.
Binary Shifts (Multiplication and Division)
Left Shift: Shifting binary digits left by one place doubles the number (multiplication by 2). Each left shift multiplies by another power of 2.
Right Shift: Shifting binary digits right by one place halves the number (division by 2). Each right shift divides by an additional power of 2.
Applications: Binary shifts are used in optimisation to perform fast multiplications and divisions by powers of two.
Characters (Text Representation)
ASCII (American Standard Code for Information Interchange): A 7-bit code representing 128 characters, including letters, digits, and symbols. Extended ASCII uses 8 bits, allowing for 256 characters, covering additional symbols.
Unicode: A 16-bit or variable-length coding system representing over 65,000 characters, covering multiple languages and symbols globally.
Images
Colour Depth: Refers to the number of bits used per pixel to represent colour. Higher colour depth allows more colours but increases file size.
Image Size: The dimensions of an image, usually measured in pixels (width x height).
Image File Size: Calculated by multiplying the image’s dimensions by its colour depth. Higher resolution or colour depth increases file size.
Resolution: The pixel density of an image, typically measured in pixels per inch (PPI). Higher resolution provides more detail.
Metadata: Extra information stored with an image file, such as dimensions, colour depth, date, and location. Metadata helps interpret and display the image correctly.
Sound
Sample Rate: The number of sound samples taken per second, measured in Hertz (Hz). Higher sample rates capture more audio detail but increase file size.
Bit Depth: The number of bits used to represent each sound sample. Higher bit depth improves audio quality but increases file size.
Bit Rate: The amount of data processed per second in a sound file, typically measured in kilobits per second (kbps). Higher bit rate increases sound quality but also file size.
Compression
Lossy Compression: Reduces file size by permanently removing some data. Commonly used in images (JPEG) and audio (MP3) where perfect reproduction is not essential. Lossy compression reduces quality to save space.
Lossless Compression: Reduces file size without losing any original data. Commonly used for text files (e.g., ZIP) or high-quality images (e.g., PNG). Lossless compression retains all data but typically achieves less reduction than lossy methods.