title: Rescuing a DivisionByZero with default value returns NaN in ruby?
body: <p>I would expect the begin rescue to set ratio to zero but instead it gets set to <code>NaN</code> which is incredibly frustrating when I am rescuing the error to provide a default value.</p>
  
  <pre><code>  ratio = begin
              0.0 / 0.0
            rescue ZeroDivisionError
              0
            end
  
    ratio = 0 if ratio.nan?
  </code></pre>
  
  <p>The code I would like to get rid of is the <code>ratio = 0 if ratio.nan?</code> why is that needed?</p>
  
  <p><strong>Edit</strong>
  new code looks like:</p>
  
  <pre><code>  ratio = bet_money_amount_cents.to_f / total_amount.to_f
    ratio.nan? ? 0 : ratio
  </code></pre>