1.4.1 Data types - Suprit Flashcards
Define Real Numbers
Positive or negative numbers that typically have a decimal point
Define Integer
A whole number
Define Characters
Any symbol used by the computer
Define String
A collection of characters stored in succession
Define Boolean
Represents True or False
How do computers store whole numbers?
Computers store whole numbers as binary
How many bits make up a nibble?
4 bits
How many nibbles make up a byte?
2 nibbles
Convert binary number 1101 to denary
13
How many bits in a kilobyte?
8000
Convert 47 into binary
101111
What is 1011 + 1110?
(1)1001
(1) is an overflow
What does 0 and 1 at the start of a binary number represent in Sign Magnitude?
0 = Positive Number
1 = Negative Number
If 10101101 = 173, what does Sign Magnitude number 010101101 mean in denary?
It’s also 173
Convert -105 to a Sign Magnitude number
101101001
What is another way to represent positive and negative numbers in binary?
Two’s Complement
How do you convert a binary number into Two’s Complement?
Flip all of the individual bits and add 1
Example - 00000111 (7) becomes 11111000 when its initially flipped, and becomes 11111001 (-7) once 1 has been added on.
How does subtraction work in Two’s Complement?
It works by adding a negative number to a positive number
Subtract 10100 from 01000 in Two’s Complement.
11100 (-4)
What base is Hexadecimal?
Base 16
What numbers and characters are used in hexadecimal?
Numbers 0-9 and Characters A-F
How do you convert Hexadecimal to Binary?
- Split the Hexadecimal number into individual digits
- Convert each digit into denary
- Convert the denary into binary nibbles (4 bits)
- Combine the nibbles together to get the answer.
Convert F1A2 to binary
Answer = 1111000110100010
Explanation -
1. Split F, 1, A, and 2
2. Convert each digit -
F = 15
1 = 1
A = 10
2 = 2
3. Convert the denary into binary nibbles -
15 = 1111
1 = 0001
10 = 1010
2 = 0010
4. Combine them -
1111000110100010
How do you convert hexadecimal to denary?
- Split the Hexadecimal number into individual digits
- Convert each digit into denary
- Convert the denary into binary nibbles (4 bits)
- Combine the nibbles together to get the answer.
- Convert the binary number into denary
Convert F1A2 into denary
Answer = 61858
Explanation -
1. Split F, 1, A, and 2
2. Convert each digit -
F = 15
1 = 1
A = 10
2 = 2
3. Convert the denary into binary nibbles -
15 = 1111
1 = 0001
10 = 1010
2 = 0010
4. Combine them -
1111000110100010
5. Convert into binary -
1111000110100010 = 61858
What 2 parts make up Floating Point Numbers in Binary?
Mantissa and exponent
What does the mantissa represent?
The original number
What does the exponent represent?
The shift in the decimal point
Is there a leading sign bit in Floating Point Binary?
Yes
How do you convert floating point binary into denary?
- Check if the sign bit is positive (0) or negative (1)
- The mantissa has the binary point (binary equivalent of decimal point) after the most significant bit. Make sure to place this there.
- Convert the exponent into decimal (it’s in two’s complement, so check if it starts with a 0 or a 1)
- Move the binary point by the same number of times that represents the exponent, moving it left if its negative, and moving it right if its positive.
- Now convert into denary
Convert 01100100111000101 to binary, where this number starts with a sign, has a 10 bit mantissa, and has a 6 bit exponent.
A = 50.4375
Explanation -
1. Check if the sign bit is positive or negative (0 = Positive)
2. Place binary bit after most significant bit in mantissa -
1.100100111
3. Convert the exponent -
000101 = 5
4. Move the binary point depending on the exponent -
Exponent = 5, so 1.100100111 = 110010.0111
5. Convert 110010.0111 into denary -
110010.0111 = 50.4375
How do you normalise binary numbers?
- Split the number into its mantissa and exponent
- Adjust the mantissa so that it starts with 01 or 10
- Add zeroes to the end depending on how many bits the mantissa was adjusted by
- Increase/Decrease the exponent depending on how the mantissa was changed.
Normalise 000110100101, which has an 8 bit mantissa and a 4 bit exponent
A = 011010000011
Explanation -
1. Split Mantissa and Exponent -
M = 00011010
E = 0101
2. Adjust the mantissa so it starts with 01 or 10 -
00011010 = 011010
3. Add zeroes on the end to make it an 8 bit number again -
011010 = 01101000
4. Adjust the exponent -
As the mantissa increased by 2 bits, the exponent must decrease by 2
0101 = 0011
How do you add floating point binary numbers together?
- Adjust the exponents so both of them are the same
- Add the mantissas together
- Normalise if necessary
What is 00001000011 + 00001010010? Both numbers have a sign bit, a 6-bit mantissa and a 4-bit exponent.
- Adjust exponents so they are both the same -
0011 = 0010
0010 = 0010
000100 becomes 001000 due to the change in exponent - Add the mantissas -
001000 + 000101 = 001101 - Normalise -
00011010010 becomes 00110100001
How do you subtract floating point binary numbers?
- Make the exponents the same
- Convert the mantissa of the number to be subtracted into two’s complement. Do this by flipping all the bits and adding 1
- Add the numbers
- Normalise answer
What is a logical shift left the same as?
Multiplication
What is a logical shift right the same as?
Division
What does an AND mask do?
Multiplies inputs, so 1*1 = 1, but anything involving a 0 = 0
What does an OR mask do?
If either bit is 1, 1 will be outputted, otherwise 0 will be outputted
What happens to the binary number 00101011 when an AND mask of 10111011 has been applied?
A = It becomes 00101011
Explanation -
When applying the mask, because the mask is an AND mask, the rules of AND are applied. Therefore, when following the rules, you get 00101011.
What happens to the binary number 00101011 when an OR mask of 10111011 has been applied?
A = 10111011
Explanation -
The mask is an OR mask, so you apply the rules of OR when applying the mask.