title: Check if number is NaN
body: <p>I'm trying to check if a variable I have is equals to NaN in my Ruby on Rails application.</p>
  
  <p>I saw this <a href="https://stackoverflow.com/questions/19154461/ruby-on-rails-how-to-deal-with-nan">answer</a>, but it's not really useful because in my code I want to return 0 if the variable is NaN and the value otherwise:</p>
  
  <pre><code> return (average.nan ? 0 : average.round(1))
  </code></pre>
  
  <p>The problem is that if the number is not a NaN I get this error: </p>
  
  <pre><code>NoMethodError: undefined method `nan?' for 10:Fixnum
  </code></pre>
  
  <p>I can't check if the number is a Float instance because it is in both cases (probably, I'm calculating an average).
  What can I do? 
  It is strange only to me that a function to check if a variable is equals to NaN is avaible only to NaN objects?</p>