Cope with NaNs and Infinity.