Data Representation Flashcards
What is a bit?
A binary digit (0 or 1) (no voltage/voltage) (off/on)
What is a byte
8 bits
What is word size
The number of bits the processor can deal with in a single operation
E.g. if you have a 64 bit PC, it has a word size of 64 bits
How do you convert binary to decimal
Write column headings over each binary digit
128 64 32 16 8 4 2 1
1 0 1 0 1 0 1 1
128 + 32 + 8 + 2 + 1 = 171
How do you convert decimal to binary
Start with your decimal number (e.g. 83)
Write the column headings up to the first number bigger than 83
128 64 32 16 8 4 2 1
0 1 0 1 1 0 1 1
83 - 64 = 29
Put a 1 under the first number smaller or the same size as 29
29 - 16 = 13
Same again
16 - 13 = 3
Same again
3 - 2 = 1
Same again
How do you do binary addition
Like column addition
Each bit is added together
If the result is 2 or 3 then the first bit is carried over to the next column
Why do we use hexadecimal?
Because it keeps the numbers much shorter and easier to read
What are the 16 symbols used in hexadecimal
0 - 9 and A - F
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
How do you convert binary to hexadecimal
Split into groups of 4 bits and write the column headings 8, 4, 2, 1 over each set
8 4 2 1 8 4 2 1
E.g. 11101011 is therefore 1 1 1 0 | 1 0 1 1
1st set of 4 = 8+4+2 = 14, in hexadecimal that is E
2nd set of 4 = 8+4+2 = 14 in hexadecimal that is E
Therefore EE is the answer
Convert hexadecimal to binary
E.g. 30F
8 4 2 1 |8 4 2 1|8 4 2 1
0 0 1 1 |0 0 0 0|1 1 1 1
Proof:
First set of 4 = 2+1 = 3, in hexadecimal that is 3
Second set of 4 = 0, in hexadecimal that is 0
Third set of 4 = 8+4+2+1 = 15, in hexadecimal is F
Answer is 30F
How many characters are in the ASCII character set
127 characters
What does the ascii character set do
The ascii character set allocates each character with a number between 0 and 127
What is the recommend method for representing characters in modern day?
Unicode
How are integers usually represented
They are usually represented in Twos complement
How are real numbers represented (numbers that include fractions/values after the decimal point)
Normalised floating point
What is a method for recording signed integers
Sign and magnitude
The left-most bit is used as the sign bit
0 = + 1 = -
What is the range of numbers that can be stored in 8 bits (sign and magnitude)
-127 to +127
What is the range of numbers that can be stored in 8 bits unsigned
0 to +255
How do you make a binary number twos complement
To make 44 into -44 we must do a process called taking the twos complement
I.e. start at the right hand side, copy each bit up to and including the first 1 and then reverse the rest
What is the range of numbers that can be held in 8 bits twos complement
-128 to +127
How do you do binary arithmetic subtraction
25 - 10 will be 25 + (-10)
25: 00011001
10: 00001010
Taking the 2s complement to make +10 into - 10
-10: 11110110
Then do column method
= 15
What is a logical shift
Logical shift left
Before: 1 0 0 1 1 0 1 1
After: 0 0 1 1 0 1 1 0
All bits move left, bit falls off the end and a 0 appears on the right
Logical shift right
Before: 1 0 0 1 1 0 1 1
After: 0 1 0 0 1 1 0 1
All bits move right, bit falls off the end and a 0 appears on the left
What is a arithmetic shift
- arithmetic shift left is identical to logical shift left I.e. 0 always appears. 1 shift multiples the number by 2 (shift twice to multiply by 4, three times to multiply by 8 etc)
- arithmetic shift right looks at the sign bit. If it is a 1 a 1 appears as the new digit. If it is a 0 a 0 appears as the new digit. Shift right divides the number by 2 (shift twice to divide by 4, three times to divide by 8 etc.)
How do you do binary multiplication
-works similar to long multiplication
0 0 0 1 1 0 1 0 0 1 0 1 x ----------------------------------- 1 0 1 1 0 1 1 0 1 ----------------------------------- 1 0 0 0 0 0 1 0 = 130
- left shift second number until right most bit is under each 1 in the first
- add up each value