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?

A

N/A

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?

A

7.5

23
Q

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

A

0.0078125

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
Q

What is the machine epsilon equal to?

A

2**(1-d) where d is the number of bits in the fraction.

26
Q

What are the consequences from a lack of accuracy of floating point numbers?

A

Things rarely add up because of rounding errors.
Order of summation matters.
Maximum error when adding n values to x is < (nepsilonx)/2
Mixed signs can cause problems.

27
Q

What are floating point numbers called in R?

A

Numeric

28
Q

How many bits are used for floating point numbers in R?

A

64

29
Q

How are the bits distributed to the components making up a floating point number in R?

A

1 - sign
11 - exponent
53 - fraction

30
Q

What is the largest possible floating point number in R?

A

8.98 x 10**(307)

31
Q

What is the machine epsilon in R?

A

2.20x10**(-16)

32
Q

What is returned for overflow of a floating point number in R?

A

+inf and -inf

33
Q

What does NaN mean in R?

A

Not a number

34
Q

What are underflows for floating point numbers set to in R and what is the warning message?

A

0, no warning generated.

35
Q

How can you deal with floating point limitations?

A
  • 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
Q

What are the advantages of floating point numbers in R?

A

Wider applicability

Wider range than fixed point

37
Q

What are the disadvantages of floating point numbers in R?

A

Results are not exact

Slow

38
Q

How is the correspondence between stored numbers and displayed symbols determined?

A

By a character set

39
Q

What are 3 examples of character sets and what are the numbers of bits in the systems?

A

ASCII - 7 bit system
Extended ASCII - 8 bit system
UNICODE - 16 bit system