[Unit 1.4.1] Data Types Flashcards

data types

1
Q

define data type

A

nature of data a variable can hold

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

what do data types specify

A

kind of values that can be stored

what operations can be performed on them

how data is stored in memory

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

why are data types important

A

error prevention

efficient memory use

performance optimisation

code clarity and maintainability

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

what is the difference between data types and data structures

A

types - low level and intrinsic to variables

structures - high level and organise multiple variables

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

define character code

A

unique binary sequence represent a single letter

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

define character set

A

standardised collection of characters and their codes to represent them

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

what is ASCII

A

American Standard Code for Information Interchange

originally used 7 bits. 128 combinations (0-127)

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

what is extended ASCII

A

8 bits, 256 characters (0-255)

-additions were non-standard and varied between countries

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

what are the disadvantages of ASCII

A

-256 values is not enough to represent all symbols for all languages of the world

-people made systems which were not compatible with each other

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

define Unicode

A

Unicode is a standard character set that is backwards compatible with ASCII. uses 32 bits. standard across all systems

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

features of a Array

A

Fixed size

Items can change

Can store only one data type

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

features of a List

A

Can change size

Items can change

Can store more than one data type

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

features of a Tuple

A

Fixed size

Items can’t change

Can store multiple data types

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

what are unsigned values

A

integers have positive values

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

what are signed values

A

integers can be positive or negative

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

how does “sign and magnitude” work

A

uses MSB to determine if value is negative or positive
0 is positive
1 is negative

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

what are the disadvantages to sign and magnitude

A

halves the highest value we can represent
complicates arithmetic

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

how does twos complement work

A

MSB is a negative value (e.g in 8 bits the MSB would become -128)
thus:
0 is positive
1 is negative

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

how do you convert from regular binary to twos complement (+ -> -)

A

write out the positive value
flip all the bits to the left of LSB (keep LSB same)

20
Q

what values can you represent in 8 bits using sign and magnitude

A

-127 to 127

21
Q

what values can you represent in 8 bits using twos complement

A

-128 to 127

22
Q

what are the rules for binary addition

A

0+0 = 0
0+1 = 1
1+1 = 0 (carry 1)
1+1+1 = 1 (carry 1)

23
Q

what are the rules for binary subtraction

A

0-0 = 0
0-1 = 1 (flip 0s till you get to 1)
1-0 = 1
1-1 = 0

24
Q

how can you do binary subtraction using twos complement

A

17-14 is the same as 17+(-14)
so switch 14 into twos complement
and do binary addition
ignore overflow

25
Q

what is bitwise manipulation

A

modifying data by changing bits within byte

26
Q

what does a shift to the left do

A

multiplies by 2

27
Q

what does a shift to the right do

A

divides by 2

28
Q

how can you multiply by 6 on a binary number

A

first multiply original value by 2
then multiply original value by 4
add these two values together

29
Q

how do you do arithmetic shift

A

same as binary shift just keep the MSB the same

30
Q

what is the logical operator for AND

A

2 inputs, a D, one output.
both values must be true

31
Q

what is the logical operator for OR

A

2 inputs, spaceship, one output, either or both values must be true

32
Q

what is the logical operator for XOR

A

2 inputs, ), spaceship, one output, either but not both values must be true

33
Q

what is bit masking

A

keep, change or remove desired part of information by imposing a mask over its bits

34
Q

what are the 3 masks for bit masks in terms of bitwise manipulation

A

AND to extract
OR to set
XOR to toggle

35
Q

what is fixed point form

A

binary point in fixed position. does not need to be stored in memory

36
Q

what is floating point form

A

using mantissa and exponent.

37
Q

what is the function of the mantissa in floating point form

A

main number containing point after MSB

38
Q

what is the function of the exponent in floating point form

A

where binary point is positioned. if exponent is negative point goes left. if it is positive it goes right.

39
Q

what happens if you increase the amount of bits for the mantissa

A

increase in accuracy

40
Q

what happens if you increase the amount of bits for the exponent

A

increase in range

41
Q

define “normalisation”

A

moving binary point of decimal number

42
Q

why do we normalise numbers

A

to maximise accuracy and range for given number of bits

43
Q

how do you tell if a number is normalised

A

positive would start 01
negative would start 10

44
Q

how do you normalise a floating point

A

adjust exponent
-move right (increase mantissa) decrease exponent
-move left (decrease mantissa) increase exponent

45
Q

how do you convert from denary to floating point

A

write it in fixed point first in twos comp
normalise
write out fully

46
Q

how do you do addition/subtraction of floating point

A

normalise both numbers
make exponents equal (smaller->larger)
perform calculation
normalise result