Math 441
Numbers in Computers
Numbers in Computers
- Finite memory
- no irrationals!
- limited number of decimals
- limited size of denominator
- limited precision!
- numbers cannot be arbitrarily small
- numbers cannot be arbitrarily large
- Speed concerns
- operations
- hardware: very fast but rigid
- software: slow but flexible
“Hardware” numbers
- Binary
- Fixed number of “bits”
- Several different “types” of numbers:
- Integers:
- unsigned
- signed
- Floating point numbers
Unsigned Integers
- Non-negative
- Each bit is one binary digit
- \(2^{\text{number of bits}}\) different values
- Smallest is 0
- Largest is \(2^{\text{number of bits}} - 1\)
- What happens when a result of a calculation is larger than that?
Signed Integers
- Different designs
- The highest bit represents the sign
- Two’s complement:
- Positive numbers are regular binary numbers using all except the highest bit
- To represent a negative number, we represent the corresponding positive number, flip all the digits (including the sign bit), and add 1.
- What is the largest (most positive) number?
- What is the smallest (most negative) number?