Fix NaN and Infinity on Win64.

Using the numerical limits (e.g. std::numeric_limits<double>::quiet_NaN()) seems not return the expected value.
This fixes issue #750.