“You’re sitting there and you’re implementing some numeric algorithm, and you want to use floating point cause it’s fast, and most importantly floating point is generally good most of the time […], things usually work. This problem is: what happens when it doesn’t and you get errors?”
When things “usually work,” but sometimes don’t, what can you do? As Tom Switzer points out, there are a three options:
- Use Double, live with the errors
- Use high precision type, live with performance loss
- Or, you can use floating point filters
This talk is all about that third option.
Typically, when implementing numeric algorithms, common wisdom suggest that between speed, correctness, or simplicity, you can choose only 2. As Tom Switzer argues, though, by using floating point filters when you can and using high precision types when you can’t, you might be able to have all three.
It’s not entirely simple, “the devil is the details,” but Tom’s talk at NE Scala 2015 describes what to look out for.