Fix rounding to NaN