Lecture 4 - An introduction to computer arithmetic Flashcards
What are numbers on a computer?
A collection of binary digits (bits)
What are the two different ways numbers are represented on a computer?
Fixed point and floating point
What is a byte?
Short for binary term.
8 bits
Enough to hold a single character of text
What is a word?
Natural data size of a computer.
Depends on the CPU but for most desktop systems it is 32 bits (64 for newer systems)
What is a kilobyte?
2**10 bytes
What is a megabyte?
2**20 bytes
What is a Gigabyte?
2**30 bytes
What does the first number of a fixed point number represent?
The sign of the integer
0 - positive
1 - negative
What base are bits in?
Base 2
How do you multiply a fixed point number by a power of 2?
Shift the bits left
How do you multiply a fixed point number by a number which is not a power of 2?
Use the shift and ass algorithm. Express as a sum of powers.
How do you divide a fixed point number by a factor of 2?
Shift right. Drop the fractional part
What is overflow?
When the fixed point number you are trying to produce cannot be written with the number of bits being used.
What is fixed point data called in R?
Integers
How many bits are used to store fixed point data in R?
32
What is returned when you overflow a fixed point number on R?
N/A
Advantages of fixed point numbers in R.
- Results are exact
- Fast
Disadvantages of fixed point numbers in R.
- Limited applicability: integers and relaxed
- Limited range.
What are the 4 different components to make up a floating point number in R?
Sign
Fraction - unsigned integer
Base
Exponent - signed integer
What are the number of bits assigned to each component making up a floating point number on R using an 8 bit system?
1 bit for sign
3 bits for exponent
4 bits for the fraction
Why are there limitations with floating point numbers?
As the fraction and exponent are stored in a fixed number of bits.
What is the largest possible floating point number in an 8 bit system?
7.5
What is the smallest possible floating point number in an 8 bit system?
0.0078125
What is the machine epsilon and what does it govern?
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.