Handle NaN and ±Infinity

Closes #121