Reduce undefined behaviour of casting NaN to an integer type