Data Representation Flashcards
What are natural numbers?
Natural numbers are position-only integers: N = {0, 1, 2, 3…}
What are integers?
Integers are numbers that can be expressed without a decimal component. These are inclusive of negative numbers and zero: Z = {….., -2, -1, 0, 1, 2…}
What are rational numbers?
Rational numbers are those that can be expressed as a fraction. This means that all integers are rational numbers. Q = {… 0.5, 1, 1.5…}
What are irrational numbers?
Irrational numbers are those that cannot be written as a fraction.
What are real numbers?
Real numbers encompass all of the numbers sets as a set of all possible real-world quantities.
R = {N, Z, Q}
What are ordinal numbers?
Ordinal numbers are numerical values that hold the position of an object when it is placed in an order.
What is decimal?
Denary is represented using powers of 10 for each position of the number. It has the radix of 10.
What is binary?
Binary representations are made up of groups of bits to convey a value using a series of 1s and 0s. Binary is represented as powers of 2.
What is hexadecimal?
This system uses 16 digits, there are only ten symbols in the denary number system (0-9) and a further six symbols (A-F) are used to represent the remaining six digits . It uses less memory to store more numbers- 256 numbers in two digits whereas decimal number 100 numbers in two digits;
Why is hexadecimal used as a shorthand for binary?
The main reason for this is that long sequences of binary digits are hard to read and understand for humans. For example, to represent 256 in binary it is 100000000 but in hexadecimal it is 100.
Converting binary to denary
Just add up place values
Converting denary to binary
Keep dividing by 2.
145/2 = 72 R 1
72/2 = 36 R 0
36/2 = 18 R 0
18/2 = 9 R 0
9/2 = 4 R 1
4/2 = 2 R 0
2/2 = 1 R 0
1/2 = 0 R 1
= 10010001 (2)
Converting binary to hexadecimal
Split it:
00101111
1) 0010(2) = 2(10) = 2(16)
2) 1111(2) = 15(10) = F(16)
= 2F(16)
Converting hexadecimal to binary
Find the equivalent denary number for each of the hex digit then convert those into binary.
FA
F = 15 = 1111
A = 10 = 1010
= 11111010(2)
Converting denary to hexadecimal
- Divide denary number by 16 and write down the result and the remainder
- Repeat the division until you get a result of 0
- Convert the denary remainders to their hex equivalent
- Write the remainders in reverse
For 125:
125/16 = 7 R13
7/16 = 0 R 7
13 = D, 7 = 7
7D(16)
Converting hexadecimal to denary
- Separate the hex digits and find their equivalent denary values
- Use the hexadecimal place vales table to multiply each value
- Add the results of the multiplications together
F8(16)
- F = 15, 8 = 8
1516 = 240
81 = 8
F8 = 240+8 = 248(10)
What is a bit?
A bit is the most basic unit of the data representation used in computer systems and conveys the state of 1 or 0.
What is a byte?
A byte is 8 bits and it represents the small unit of addressable memory
What is a nibble?
A nibble is 4 bits.
What are words?
Words are groups of bytes in a sequence.
What is a Kilobyte?
10^3 bytes
What is a Megabyte?
10^6 bytes
What is a Gigabyte?
10^9 bytes
What is a Terabyte?
10^12 bytes
What is a Kibibyte?
2^10 bytes
What is a Mebibyte?
2^20 bytes
What is a Gibibyte?
2^30 bytes
What is a Tebibyte?
2^40 bytes
What is the 2^n formula for?
- Each bit in a binary number can be either 0 or 1.
- If you have one bit, you can represent 2 different values: 0 or 1.
- If you have two bits, each bit can independently be 0 or 1, giving you 2 * 2 = 4 different combinations: 00, 01, 10, 11.
- If you have three bits, each bit can independently be 0 or 1, giving you 2 * 2 * 2 = 8 different combinations: 000, 001, 010, 011, 100, 101, 110, 111.
What is the difference between kB and KiB?
1 kB = 1,000 bytes whereas 1 KiB = 1024 bytes; it provides more precision
What is the difference between unsigned binary and signed binary?
Unsigned integers have positive values but signed integers can be positive or negative. However representing negative integers using sign magnitude isn’t perfect because it allows for two values of zero: a positive zero and a negative zero. Also, by assigning a sign bit you decrease the range of magnitude. An unsigned byte can represent the numbers 0 to 255, whereas a signed byte can only represent -127 to 127.
Classifications of signed representations
Ones complement, twos complement
What is ones complement?
In ones’ complement representation, to represent a negative number, you invert (flip) all the bits of the corresponding positive binary number. The leftmost bit is still used to represent the sign. Range is for highest (2(^n-1) -1) and lowest is -(2(^n-1) -1).
What is twos complement?
Take the two’s complement of the positive equivalent by flipping all the bits and then adding 1. The range is -2^(n-1) to 2^(n-1) - 1.
In unsigned binary what are the minimum and maximum values?
0 to 255
Adding two unsigned binary integers
0+0 = 0
0+1 = 1
1+ 0 = 1
1+1 = 0 carry 1
1+1+1 = 1 carry 1
Subtracting two unsigned binary integers
0-0 = 0
1-0 = 1
1-1 = 0
0-1 = 1
Representing signed integers using one’s complement
Write in positive version then flip the values.
Representing signed integers using two’s complement
- For positive numbers the MSB needs to be 0
- For negative numbers the MSB needs to be 1
Subtraction with two’s complement
Convert to two’s complement and do subtraction