Support +inf and -inf where doubles are returned

* Replaces all uses of Double.valueOf with a method that supports positive
and negative infinity.
* Adds positive and negative infinity to the tests