Use finite math.

- Fixes issue with gcc 4.9.0.
- std::numeric_limit<float>::infinity is non-finite.