Data Types Flashcards

1
Q

What is a primitive data type?

A

A base data type that is provided by “most” programming languages for proccessing and storing data

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

What are the primitive data types?

A

Integer
Real/Float
Char
String
Boolean

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

How is data stored in a computer?

A

In binary (1s and 0s)

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

What is Hexadecimal?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you convert from hex to binary (A5)?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you convert from hex to denary (A5)?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you convert from binary to hex (10011101)?

A

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

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

What is a character set?

A

A representation of binary numbers that maps each unique binary number to a unique character

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

What are the two character sets?

A

Unicode - 32 bits, more characters
ASCII - 8 bits (7 bits for non-extended), only standard english characters

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

How can negative numbers be represented in binary?

A

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

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

Why is Two’s Complement better than Sign and Magnitude?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are decimal numbers represented in binary?

A

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

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

What is normalisation of floating point binary numbers?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you add 2 Floating Point Binary Numbers?

A

Convert both into their fixed point binary forms and add them together, turn back into a normalised floating point binary value

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

What is a bitwise mask?

A

A binary number that is used to modify another number with the AND, OR or XOR operations

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

What is a logical shift?

A

Shifting an unsigned binary number to the left or right involves moving the binary value in that direction and padding the missing values, any values that cannot fit are dropped from the number

16
Q

What is an arithmetic shift?

A

Allows for the right shifting of signed numbers by padding with 1s if the MSB is a 1 and 0s is the MSB is 0

17
Q

What does bitwise AND do?

A

if both bits are 1 the output is 1
this can be used to extract a certain section of the binary number

18
Q

What does bitwise OR do?

A

if 1 or both of the bits are 1 the output is 1
this can be used to set specific bits of a binary number and leave the rest unaffected

19
Q

What does bitwise XOR do?

A

if only 1 of the bits is a 1 the output is 1
this can be used to toggle specific bits of a binary number