Lecture 4 - An introduction to computer arithmetic Flashcards

1
Q

What are numbers on a computer?

A

A collection of binary digits (bits)

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

What are the two different ways numbers are represented on a computer?

A

Fixed point and floating point

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

What is a byte?

A

Short for binary term.
8 bits
Enough to hold a single character of text

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

What is a word?

A

Natural data size of a computer.

Depends on the CPU but for most desktop systems it is 32 bits (64 for newer systems)

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

What is a kilobyte?

A

2**10 bytes

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

What is a megabyte?

A

2**20 bytes

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

What is a Gigabyte?

A

2**30 bytes

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

What does the first number of a fixed point number represent?

A

The sign of the integer
0 - positive
1 - negative

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

What base are bits in?

A

Base 2

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

How do you multiply a fixed point number by a power of 2?

A

Shift the bits left

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

How do you multiply a fixed point number by a number which is not a power of 2?

A

Use the shift and ass algorithm. Express as a sum of powers.

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

How do you divide a fixed point number by a factor of 2?

A

Shift right. Drop the fractional part

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

What is overflow?

A

When the fixed point number you are trying to produce cannot be written with the number of bits being used.

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

What is fixed point data called in R?

A

Integers

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

How many bits are used to store fixed point data in R?

A

32

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

What is returned when you overflow a fixed point number on R?

17
Q

Advantages of fixed point numbers in R.

A
  • Results are exact

- Fast

18
Q

Disadvantages of fixed point numbers in R.

A
  • Limited applicability: integers and relaxed

- Limited range.

19
Q

What are the 4 different components to make up a floating point number in R?

A

Sign
Fraction - unsigned integer
Base
Exponent - signed integer

20
Q

What are the number of bits assigned to each component making up a floating point number on R using an 8 bit system?

A

1 bit for sign
3 bits for exponent
4 bits for the fraction

21
Q

Why are there limitations with floating point numbers?

A

As the fraction and exponent are stored in a fixed number of bits.

22
Q

What is the largest possible floating point number in an 8 bit system?

23
Q

What is the smallest possible floating point number in an 8 bit system?

24
Q

What is the machine epsilon and what does it govern?

A

The machine epsilon is the smallest positive integer such that epsilon + 1.0 is not equalto 1.0. It governs the relative accuracy of the system.

25
What is the machine epsilon equal to?
2**(1-d) where d is the number of bits in the fraction.
26
What are the consequences from a lack of accuracy of floating point numbers?
Things rarely add up because of rounding errors. Order of summation matters. Maximum error when adding n values to x is < (n*epsilon*x)/2 Mixed signs can cause problems.
27
What are floating point numbers called in R?
Numeric
28
How many bits are used for floating point numbers in R?
64
29
How are the bits distributed to the components making up a floating point number in R?
1 - sign 11 - exponent 53 - fraction
30
What is the largest possible floating point number in R?
8.98 x 10**(307)
31
What is the machine epsilon in R?
2.20x10**(-16)
32
What is returned for overflow of a floating point number in R?
+inf and -inf
33
What does NaN mean in R?
Not a number
34
What are underflows for floating point numbers set to in R and what is the warning message?
0, no warning generated.
35
How can you deal with floating point limitations?
- rewrite expressions to avoid overflow - normalise scalars - change exact tests to good enough tests - be careful about order of operations - use double precision (uses twice the memory) Many of these show a trade between speed and accuracy
36
What are the advantages of floating point numbers in R?
Wider applicability | Wider range than fixed point
37
What are the disadvantages of floating point numbers in R?
Results are not exact | Slow
38
How is the correspondence between stored numbers and displayed symbols determined?
By a character set
39
What are 3 examples of character sets and what are the numbers of bits in the systems?
ASCII - 7 bit system Extended ASCII - 8 bit system UNICODE - 16 bit system