Data Types Flashcards
What is a primitive data type?
A base data type that is provided by “most” programming languages for proccessing and storing data
What are the primitive data types?
Integer
Real/Float
Char
String
Boolean
How is data stored in a computer?
In binary (1s and 0s)
What is Hexadecimal?
a base-16 number system, which can represent a nibble with 1 character, used typically for colours and longer binary numbers for them to be easier to read by humans
How do you convert from hex to binary (A5)?
Seperate each digit and write the nibble they each are and join them together
A5
A (base-16) = 10 (base-10) = 1010
5 (base-16) = 5 (base-10) = 0101
10100101
how do you convert from hex to denary (A5)?
Convert each hex digit into its value then multiply the left most digit by 16 and the right by 1 add them together
A5
A (base-16) = 10 (base-10)
5 (base-16) = 5 (base-10)
10*16=160
160+5 = 165
How do you convert from binary to hex (10011101)?
Split the binary number into nibbles and convert into hex digits, stick them together
1001 = 9 (base-10) = 9 (base-16)
1101 = 13 (base-10) = D (base-16)
9D
What is a character set?
A representation of binary numbers that maps each unique binary number to a unique character
What are the two character sets?
Unicode - 32 bits, more characters
ASCII - 8 bits (7 bits for non-extended), only standard english characters
How can negative numbers be represented in binary?
Sign and Magnitude = the MSB (Most Significant Bit) is a sign 1 for negative 0 for positive
Two’s Complement = the MSB is the negative version of the number value of its place e.g. for 8 bits the MSB represents 128, so it would be -128
Why is Two’s Complement better than Sign and Magnitude?
Two’s complement allows for negative numbers to be easily added together, with no changes and allows for subtraction through the negating of numbers
How are decimal numbers represented in binary?
Fixed Point Binary = A fixed decimal point in the binary number halving as you go to the right and doubling as you go to the left
Floating Point Binary = A mantissa holds the number and the exponent holds where the binary point should be placed allowing for a much larger range of numbers and more accuracy for smaller numbers
What is normalisation of floating point binary numbers?
Making sure the start of the mantissa is 01 for positive numbers and 10 for negative numbers, otherwise there may be several ways of representing each number, which is inefficient
How do you add 2 Floating Point Binary Numbers?
Convert both into their fixed point binary forms and add them together, turn back into a normalised floating point binary value
What is a bitwise mask?
A binary number that is used to modify another number with the AND, OR or XOR operations