previous |
start |
next
Comparing Floating-Point Numbers
- Two numbers are close to another if
|x - y| <= ε
- ε is a small number such as 10-14
- Not good enough if x, y very large or very small.
Then use
|x - y| / max(|x|, |y|) <=
ε
- But if one of the numbers is zero, don't divide
by max(|x |, |y|)
previous |
start |
next