Data types Flashcards
(38 cards)
What does an AND operator do? (Mask)
AND operator is used to clear a particular bit, leaves the other bits unchanged
AND 1 and 0 meaning
Use 1 to keep the number the same
Use 0 to change the number
What does an OR operator do? (Mask)
OR operator used to set a particular bit, leaves the other bits unchanged
OR 0 and 1 meaning
0 the keep the number the same
1 to change/set the number
What does a XOR operator do? (Mask)
XOR operator used to toggle a particular bit, leaves the other bits unchanged
XOR 0 and 1 meaning
1 toggles the number
0 keeps the number the same
And truth table
0+0=0
0+1=0
1+0=0
1+1=1
OR truth table
0+0=0
0+1=1
1+0=1
1+1=1
XOR truth table
0+0=0
0+1=1
1+0=1
1+1=0
What mask do you use to make lowercase
Apply OR mask
0010 0000
What mask do you use to make uppercase
AND mask
1101 1111
Normalised floating point rules
Mantissa always starts with:
01 for positive numbers
or
10 for negative numbers
Why should you use the correct data type
Different data types take up different amounts of memory. To optimise program performance it’s important to use the correct data type where possible
What are the different data types
Integer
Real/float
Boolean
Character
String
Define primitive data type
Any basic data type provided by a language as a foundational building block
Define composite data type
Most languages allow more complex data types to be constructed from primitive data types
Define integer
Integer data type represents any positive or negative whole nunber
Define real
The real data type represents any positive or negative number including decimals or fractions
Define character
The character data type represents a single character (symbol or letter)
Define string
The string data type represents a collection of characters (not limited to letters)
Define Boolean
The Boolean data type can be used to represent one of two truth values associated with logic
Define casting
A way to convert one data type to another
What is sign and magnitude
A way of representing negative numbers
What does a positive number start with (S+M)
Positive numbers start with a 0