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