1.4.1 Data Types Flashcards
What are the 5 primitive data types?
- Real / Floating Point – Stores decimal numbers (3.141)
- Character - A single letter, number or special character (‘H’)
- String – A collection of characters (“Hello World”)
- Boolean – TRUE or FALSE
- Integer – A positive or negative whole number (24, -34)
What is casting?
The process of changing one data type into another.
What is a character set?
What are some examples?
- List of all the characters the computer can represent.
- Each character is represented by a unique binary value.
- Used to map binary values to characters.
- Examples: UNICODE and ASCII
Describe the ASCII character set
- ASCII is a character set which is a subset of UNICODE
- Uses 7 bits, or 8 bits for extended ASCII
- Fewer characters can be represented than UNICODE
- Characters from different languages cannot be represented in ASCII
Describe the UNICODE character set
- Each character is represented by 1-4 bytes.
- It supports a very large number of characters
- It is backwards compatible with ASCII
- Text using UNICODE rather than ASCII would take up more storage (roughly 4 times more)
Convert 177 to an unsigned 8-bit binary number
10110001
128+32+16+1 = 177
Convert the unsigned 8-bit binary number 10110010 to denary
128+32+16+2 = 178
Convert 188 to Hex
BC
Convert the hex FE to a denary number
11111111 = 254
Convert -49 to an 8-bit binary number using two’s complement
11001111
Convert 49 to an 8-bit binary number using two’s complement
00110001
Convert -49 to an 8-bit binary number using sign and magnitude
10110001
Add the following two binary numbers
01101010 + 00111111
10101001
Carries - 11111100
Subtract the following two binary numbers
00101111 - 00010111
00011000
An overflow should have occurred
Normalise
0001011000 001100
0101100000 001010
(Remove the two extra bits from the front of the mantissa and reduce the exponent value by 2)
Normalise
1110011000 001100
1001100000 001010
(Remove the two extra bits from the front of the mantissa and reduce the exponent value by 2)
Convert 5.25 to an 6-bit mantissa and 3-bit exponent
010101 011
Convert -5.25 to an 6-bit mantissa and 3-bit exponent
101011 011
Convert 01110 0001 to floating point denary
1.75
Convert 10010 0001 to floating point denary
-1.75
Convert 0.125 to an 6-bit mantissa and 3-bit exponent
010000 110
Convert -0.125 to an 6-bit mantissa and 3-bit exponent
110000 110
Why do we normalise floating point numbers?
Allows for more accuracy/precision from the given number of bits
So that the representation of each binary value is unique
What impact does increasing the size of the exponent have?
Increasing the number of bits used for the exponent increases the size of the number that can be stored.
What impact does increasing the size of the mantissa have?
Increasing the number of bits used for the mantissa increases the precision of the number that can be stored.