Data Types Flashcards

1
Q

What are the 5 primitive data types?

A
  • integer
  • real/floating point
  • character
  • string
  • boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an integer?

A
  • a whole number with no fractional/decimal parts
  • Can be positive or negative
  • useful for counting things
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a real/floating point number?

A
  • positive or negative number which can but don’t need a fractional part
  • useful for measuring things
  • all integers are real numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a character?

A
  • a single symbol used by a computer
  • Eg. The letters of the alphabet, numbers, special characters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a string?

A
  • a collection of characters
  • can store a single character or many characters in succession
  • useful for storing text and phone numbers starting in 0 (normal integers or floating point would get rid of the starting 0)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Boolean?

A
  • values of this data type are restricted to True and False
  • useful for storing data that can only take 2 values eg. the state of a power button
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the human counting system?

A

Base 10 - denary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the computer counting system?

A

Base 2 - binary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A single binary digit is a …

A

Bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

8 binary digits combined is a …

A

Byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

4 binary digits combined is a …

A

Nybble

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you convert from binary to denary?

A
  • the least significant bit is the one furthest right
  • The most significant bit is the one furthest left
  • the value of the columns increase by a power of 2 each one you move further right
  • if the column has a 1 in it counts the value of that column once, if there is a 0 don’t count it
  • add the value of all the columns with a 1 in them to get the binary number in denary
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you convert from denary to binary?

A
  • find the largest power of 2 which is smaller than the number you are converting, the write out the binary place values up to this value
  • subtract this value from the original value, then repeat the process until you have 0.
  • Make sure all the binary bits with 1s add up to the original value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the binary addition rules?

A

0+0+0=1
0+0+1=1
0+1+1=10 (1 is carried to next column in column addition)
1+1+1=11 (1 is carried over to next column in column addition)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the binary addition rules?

A

0+0+0=1
0+0+1=1
0+1+1=10 (1 is carried to next column in column addition)
1+1+1=11 (1 is carried over to next column in column addition)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How would you represent a binary number as a whole number of bytes?

A

You would add leading 0’s (0’s in front of the actual number) - these don’t affect the value of the binary number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do you do binary addition?

A

Do it like column addition - like up the 2 binary numbers in columns using 1s column to like them up and then apply binary addition rules
If there is a carry then put the carried one in small under the next column to the left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what are the basic binary subtraction rules?

A

0-0=1
1-0=1
1-1=0
0-1=1 (borrow 1 from the adjacent higher order digit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

how do you do basic binary subtraction?

A

do it like normal column subtraction following the rules of binary subtraction and doing carries where you need to

20
Q

what sort of counting system is hexadecimal?

21
Q

how do you represent values 10-15 using hexadecimal?

A

using letters A-F
A=10, B=11, C=12, D=13, E=14, F=15

22
Q

How do you convert from hexadecimal into denary?

A
  • use the place values of hex and multiply by the column place value
  • each column has a place value to the power of 16, with powers increasing the further left you move along
23
Q

how do you convert from denary to hex?

A
  • divide the number by 16
  • the remainder will be the rightmost hex value
  • if there’s no remainder then rightmost digit will be 0
24
Q

how do you convert from hex to binary?

A
  • convert each hex digit to a denary digit and then convert this into a binary nybble (4 bits)
  • then recombine all the nybbles in the right order to get the binary number
25
how do you convert from binary to hex?
- divide the binary number into nybbles - convert the nybble into a denary digit - convert this into hex digits and recombine the hex digits together
26
how do you represent a negative binary number using sign magnitude?
- Use the first bit - the most significant figure - as the sign bit - the rest of the number is the magnitude - the actual number - a leading 1 means a negative number - a leading 0 means a positive number
27
why is sign magnitude not the best way of representing negative numbers?
you can't do any mathematical operations on the numbers when they're in this format - the maths goes funny
28
How do you represent negative binary numbers in two's compliment?
- also works by making the most significant bit negative but it does this mathematically rather than simply saying it is negative - convert the number into binary but the positive version - change all 0's into 1's, all 1's into 0's - add 1 to the flipped version
29
how do you convert out of two's complement to find the denary number?
- subtract 1 from the two's complement number - flip the result 1's -> 0's, 0's -> 1's - convert this into denary - remember to make the denary number negative
30
how do you do binary subtraction using two's complement?
- binary subtraction is basically the same as adding a negative - so just add the negative number(s) together using binary column addition
31
what is floating point binary?
- kind of like standard form - split into mantissa and exponent - this is the info needed to work out what the actual value being represented is
32
how do you understand floating point binary (mantissa + exponent)?
- convert it to positive binary if not already done - look at the mantissa first - take it to have a binary point after the first bit - convert the exponent to decimal - positive exponent = move the decimal point right - negative exponent = move the decimal point left
33
what is normalisation?
- it is making sure that the mantissa of the floating point number is used as much as possible to make the value as precise as possible - essentially adjust it so that the mantissa starts in 01 (positive) or 10 (negative) - remove leading 0's/1's
34
how do you normalise a number?
- split the number into a mantissa and exponent - adjust mantissa so that it starts in 01 or 10 - add zeroes to the start/end of mantissa if needed - if you make the mantissa bigger (move it along left) then reduce the exponent - if you make the mantissa smaller (move it along right) then increase the exponent
35
how do you add floating point binary numbers?
- the exponents need to be equal - so equate it to the smaller exponent - change the mantissa to match the exponent - then do normal binary addition - normalise the result if needed
36
how do you subtract floating point binary numbers?
- make the exponents the same and manipulate the mantissa - then do normal binary subtraction - then normalise the result if needed
37
what is a shift?
- any shift done on a binary value is a logical shift - done by ALU - useful for division and multiplication - essentially shift all bit left or right a specified value - add leading/trailing 0's
38
What is a right shift?
when the binary value is shifted to the right the specified number of places - it decreases the value of the binary number by the relevant power of 2
39
what is a left shift?
when the binary value is shifted to the left the specified number of times - it increases the value of the the binary number by the relevant power of 2
40
what is the difference between shifting a signed bit and unsigned bit?
- signed bit - pin the sign bit to the front of the number, then shift the rest of the number - unsigned bit - just shift all digits of the number
41
What are some potential issues of doing a shift?
- overflow error - data lost during left shift - underflow error - data lost during right shift
42
What is masking?
use a binary number as a mask and combine it with a logic gate to give a different output can be used for encryption
43
what is a NOT mask?
follows same logic as NOT logic gate: - reverses the binary bits - 1 -> 0, 0 -> 1
44
what is an AND mask?
follows the same logic as AND logic gate - 2 inputs gives the following outputs: 0+0=0 1+0=0 0+1=0 1+1=1
45
what is an OR mask?
follows the same logic as OR gate - 2 inputs give the following outputs: 0+0=0 1+0=1 0+1=1 1+1=1
46
what is an XOR mask?
follows the same logic as XOR gate - 2 inputs give the following outputs: 0+0=0 1+0=1 0+1=1 1+1=0