5: Fundamentals of Data Representation Flashcards
Natural Numbers
N = {0, 1, 2, 3, …}
Integers
Z = {…, -3, -2, -1, 0, 1, 2, 3, …}
Rational Numbers
Q - the set of numbers that can be written as a fraction (includes integers)
Irrational Numbers
The set of numbers that can’t be written as a fraction
Real Numbers
R - the set of all possible real world quantities (includes natural, rational & irrational numbers)
Ordinal Numbers
Describe the numerical position of an object in a list
Counting & Measurement
Natural numbers are used for counting and real for measurement
Number Bases (3)
- Decimal (base 10)
- Binary (base 2)
- Hexadecimal (base 16)
Benefits of using Hexadecimal as Shorthand for Binary (4)
- Numbers are more compact when displayed
- It is easier for people to understand and read
- There is a lower likelihood of an error when typing in data
- It saves the programmer time when typing in data
Bit
Fundamental unit of information (0 or 1)
Byte
A group of 8 bits
Binary Values Representable with n Bits
2ⁿ
Binary Prefixes (4)
- Kibi, Ki – x2^10
- Mebi, Mi – x2^20
- Gibi, Gi – x2^30
- Tebi, Ti – x2^40
Decimal Prefixes (4)
- Kilo, k – x10^3
- Mega, M – x10^6
- Giga, G – x10^9
- Tera, T – x10^12
Unsigned vs Signed Binary
Unsigned binary can only represent positive numbers (has a sign bit of 0) whereas signed binary can represent both positive & negative
Minimum & Maximum Values in Unsigned Binary
For n bits: 0, 2ⁿ - 1
Unsigned Binary Arithmetic (2)
- Add two integers
- Multiply two integers
Two’s Complement
A possible coding scheme for signed binary
Signed Binary Operations (2)
- Represent negative and positive integers
- Perform subtraction
Minimum & Maximum Values in Signed Binary using Two’s Complement
For n bits: -2ⁿ⁻¹, 2ⁿ⁻¹ - 1
Convert Signed Binary to Decimal (4)
- Flip bits
- Add 1
- Convert to decimal as unsigned binary
- Flip the sign
Convert Negative Decimal to Signed Binary (4)
- Flip sign
- Convert to unsigned binary
- Flip bits
- Add 1
Perform Binary Subtraction (2)
- Convert the number, which is being subtracted, into signed binary
- Add the two binary numbers ignoring the overflow bit
Fixed Point Form
Numbers with a fractional part can be represented using fixed point form in binary, where the binary point is programmed into the system not stored in the data
Numbers with a Fractional Part Conversions (2)
- Decimal to binary in a given number of bits
- Binary to decimal in a given number of bits
Convert 0011 1001₂ to Decimal (4 Bits Before & After Binary Point)
8x0 + 4x0 + 2x1 + 1x1 + 0.5x1 + 0.25x0 + 0.125x0 + 0.0625x1
= 2 + 1 + 0.5 + 0.0625
= 3.5625₁₀
Convert 3.5625₁₀ to 8-bit binary (4 bits before and after binary point)
3.5625 - 2 = 1.5625
1.5625 - 1 = 0.5625
0.5625 - 0.5 = 0.0625
0.0625 - 0.0625 = 0
0011 1001₂
Differentiation between Decimal Digit Representations
Can be represented as a character code or pure binary (e.g., 65₁₀ is ‘A’ in ASCII but 01000001₂ in binary)
ASCII (3)
- Uses 7 bits to encode characters
- Can represent 128 different characters
- Extended ASCII has been developed, which uses 8 bits to encode characters
Unicode (3)
- Introduced to support a larger range of characters than ASCII
- Due to increased international communication and use of files in multiple countries
- Each character code is always interpreted as the same character
Error Checking & Correction Methods (4)
- Parity bits
- Majority voting
- Checksums
- Check digits
Parity Bits (3)
- Two types of systems: even & odd parity
- Transmitting computer attaches a parity bit to start of binary to make number of 1s in binary odd / even (e.g., for even: 0101 → 00101 & 0100 → 10100)
- Receiving computer checks there are odd / even number of 1s in binary
Parity Bits Disadvantages (2)
- Cannot detect all errors (e.g., if two bits change)
- Doesn’t show where error is, only that error has occurred
Majority Voting (2)
- Each bit is transmitted multiple times
- The receiver checks the bits it has received and if they are not all the same it assumes the one it received the most copies of is the correct value for the bit
Majority Voting Disadvantages (3)
- If there are multiple errors in a group of 3 bits, the receiving computer will correct the final bit wrongly and assume that is correct
- Transmission time is 3 times longer
- Increased processing time
Checksums (3)
- Checksum is a number which is calculated from the data in the packet
- Checksum is recalculated when packet is received
- If the checksum received in packet matches the recalculated checksum then data has been received correctly