Data types (unit 6) (Finished) Flashcards

1
Q

(6.1) What is a primitive data type?

A

A primitive data type is one which is provided by (or built into) a programming language

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

(6.1) What are some examples of primitive data types

A

Integer
real/float
boolean

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

(6.1) Why are data types important?

A

Because all data types are held in binary, so knowing the data type of the number is extremely important

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

(6.1) Why do some variables need to be defined?

A

some variables need their data types defining so that they can be properly utilized

Such as in Java

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

(6.1) What is base 10?

A

Denary- only uses 10 numbers to create every number

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

(6.1) What is base 2?

A

Binary- only uses 1s and 0s

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

(6.1) What is base 16?

A

Hexadecimal- uses 1-9 and A-F for 10-15

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

(6.1) How is denary converted to hex?

A

divide by 16 and add the remainder as a separate number

eg 43/16= 2 remainder 11
because 11= b the answer is 2b

to check that this is correct we can do
2*16= 32 + b(11)= 43

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

(6.1) How is binary converted to hexadecimal?

A

binary number is split into 2 bits and a number is made of each

eg 11101011 = 1110 1011
1110 = 14= E
1011 = 11 = B
EB

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

(6.1) What is hexadecimal used in?

A

RGB colour codes
MAC addresses
Memory locations

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

(6.1) Why is hex used?

A

A hexadecimal value is much easier to read and remember than a string of binary digits
It is quicker to write or type, since a hex digit takes up only one character, not four
There is less chance of making an error when typing hex characters than a string of 1s and 0s
It is very easy to convert to and from binary

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

(6.2) In what way are computers similar to light bulbs?

A

Data is stored and processed using combinations of ON and OFF voltages, equivalent to a lamp turning on and off where ON = 1 and OFF = 0

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

(6.2) What is a bit?

A

Each individual digit in a binary value is referred to as a bit, (from the term binary digit)

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

(6.2) What is a byte?

A

A byte is a collection of 8 bits

Two or more bytes can be grouped together to hold larger values

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

(6.2) What are the names and amounts for types of bytes?

A

kilo(kB)- 1.000
mega(MB)- 1,000,000
giga(GB)- 1,000,000,000
tera(TB)- 1,000,000,000,000

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

(6.2) What is ASCII code?

A

American Standard Code for Information Interchange, (ASCII,)- used to encode symbols found in the English alphabet

Had limitations due to the amount of characters it could contain

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

(6.2) why are numerical characters not always the same binary value as their converted value?

A

because not all numbers are going to be used in a numerical/mathematical way. For example, a house number in a database full of addresses

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

(6.2) What is Unicode?

A

Standardises the encoding of characters from all languages

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

(6.2) What are some advantages of Unicode?

A

Every character in every language can be represented

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

(6.3) How does binary addition work?

A

add the digits in the same columns, carry when the value is >1

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

(6.3) What is the problem with adding binary values?

A

it can cause overflow errors

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

(6.3) What is the formula for calculating the range of which a number of binary values can represnet?

A

2(to the power of n)- 1

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

(6.3) How are negative numbers represented in binary?

A

Sign and magnitude

Two’s compliment

24
Q

(6.3) What is sign and magnitude?

A

the first bit is taken and used as an indicator for the value being negative

This means that the value represented is smaller

In addition to this, arithmetic doesn’t work properly with this method, so Two’s compliment is much more common

25
Q

(6.3) What is two’s compliment?

A

most popular method of representing negative binary numbers

Done by flipping the binary digits and adding one

eg 01010101 (85) = 10101010 + 1 = 10101011 (-85)

26
Q

(6.3) Find -77 in two’s compliment (method of twos compliment)

A

Find the positive- 01001101 = 77
Flip the bits- 10110010
Add 1- 10110011 = -77

27
Q

(6.3) What range of numbers can be represented in negative via two’s compliment?

A

Half the amount, since the first value is used to indicate the negative value

28
Q

(6.3) At what point will overflow occur in negative numbers?

A

above 127 (assuming 8 bits)

29
Q

(6.3) How can binary fractions be made?

A

By placing a decimal point in the sequence, separating whole numbers from fraction numbers

30
Q

(6.3) What is fixed point binary?

A

The number uses a specific placement for the binary point in order to make decimal numbers

This decreases accuracy however as it is not flexible to the needs of the number

31
Q

(6.4) What is the problem with fixed point binary numbers?

A

They have reduced accuracy as they are forced to be centered around one decimal point

32
Q

(6.4) What is a mantissa?

A

Holds the main digits of a binary number

33
Q

(6.4) What is an exponent?

A

determines where the decimal point should be placed in a floating point binary number

34
Q

(6.4) What are floating point numbers?

A

Binary numbers held in more than 8 bits, including:
sign bit- tells if the number is negative or positive (1 bit)
mantissa- stores the actual number (7 bits)
exponent- dictates where the decimal point will be placed (4 bits)

35
Q

(6.4) How are negative floating point numbers converted to denary?

A

find the two’s compliment of the mantissa (ADD ONE)
work out the number normally
negative your answer

36
Q

(6.4) What is normalization?

A

The process of moving the binary point in order to make the most accurate number possible

37
Q

(6.4) How is normalization done?

A

Move the mantissa until the 1st digit after the decimal is a significant figure, minus the number of times moved off of the exponent

38
Q

(6.4) How are denary numbers converted to normalized floating point binary numbers?

A

Convert to floating point (find 88 in binary)

Normalize (add decimal point in before 1st significant digit)

39
Q

(6.4) How are negative denary numbers calculated as normalized floating point binary numbers?

A

Calculate the binary value
two’s compliment it
normalize it

40
Q

(6.5) How can bits be manipulated in binary numbers?

A
shift instructions (left/right shift by a number of bits)
masks (NOT, OR, AND, XOR)
41
Q

(6.5) What is a logical shift left?

A

MSB (most significant bit) is shifted into the carry bit, and a zero is placed in the LSB (least significant bit) spot

42
Q

(6.5) What are the uses of a logical shift left?

A

allows the user to multiply the binary number by two

43
Q

(6.5) What is a logical shift right?

A

LSB (least significant bit) is shifted into the carry bit, and a zero is placed in the MSB (most significant bit) spot

44
Q

(6.5) What are the uses of a logical shift right?

A

Halves the total value of the binary number

45
Q

(6.5) What is an arithmetic shift right?

A

same as a logical shift right, except the space left by shifting the LSB is replaced with the MSB where a 0 would normally go

46
Q

(6.5) What is an arithmetic shift left?

A

like a logical shift left, except the sign bit is preserved and a zero moves into the empty space at the end of the sequence

47
Q

(6.5) How is multiplying binary numbers done?

A

by arithmetic shifting left a number of times, depending on how many times it needs to be multiplied

48
Q

(6.5) How is dividing binary numbers done?

A

arithmetic shift right, rounds down if an odd number is divided by two

49
Q

(6.5) What is a circular shift right?

A

the carry bit is moved into the msb and the value in the lsb is moved into the carry bit

50
Q

(6.5) What is a circular shift left?

A

the value in the msb is moved into the carry bit and the carry bit into the lsb

51
Q

(6.5) What is XOR

A

exclusive OR- if one is true, then the statement is true, but if both are true, then it is false

52
Q

(6.5) What is boolean logic?

A

A form of algebra where all values are either true or false

53
Q

(6.5) What is a mask?

A

a condition applied to the comparison of two binary strings in order to provide an outcome

54
Q

(6.5) What is the use of AND mask?

A

can be used to clear a particular part of a bit

55
Q

(6.5) What is the use of an OR mask?

A

Can be used to set a particular bit

56
Q

(6.5) What is the use of an XOR mask?

A

Can be used to toggle a particular bit