1.4.1 Data types Flashcards
What is static typing?
When variables have to be defined as a certain data type before they can be used.
What is dynamic typing?
When variables do not have to be defined before they are used and can be defined when needed.
Name 4 different data types.
String, Boolean, Integer, Float/Real
What is strong typing?
When variables are locked into a set data type and will not work if used as different data types.
What is weak typing?
When variables are not locked to a certain data type and can be used as multiple data types.
What is a primitive data type?
A data type that is provided by a programming language.
Name 5 primitive data types.
Integer String Real / Float Boolean (Character)
How do we convert between denary and hexadecimal?
Denary to Hex:
Divide by 16 = First Number
Remainder = Second Number
How do we convert a number from hex to denary/
Multiply first number by 16.
Add on second number.
What are the numbers 10-15 represented by in hexadecimal?
A B C D E F
How do we convert a number from binary to hex?
Split in to nibbles
First nibble = first number
2nd nibble = second number
so on…
How do we convert from Hex to binary?
First number = first nibble
2nd number = second number
so on…
combine nibbles
Why is hexadecimal used?
Because they are easier to remember and write / type for humans
What are the rules for binary addition?
0 + 0 = 0
1 + 0 = 1
1 + 1 = 0 (carry 1)
1 + 1 + 1 = 1 (carry 1)
What is an overflow error?
When two binary numbers are added together and the new value exceeds the maximum number of bits allowed.
How do we represent negative numbers using sign and magnitude?
We make the leftmost bit (the most significant bit) a sign bit.
If this is 0, the number is positive
If this is 1 the number is negative