Handle NaN, -Infinity and Infinity in the toRational for Float/Double (#3676)