This is something new thing to me , NaN, standing for not a number in computing world. I know that 'divide by zero' is common scenario where most of the languages throws exceptions.
It is always hard to deal with 'infinity' in computer world. Just go through wiki what is NaN generation scenarios.
https://en.wikipedia.org/wiki/NaN