Convert nan/infinity to uint 0 to match MS.NET. Fixes #13927.