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