Different ways to do division in Ruby

This was always confusing me, since Ruby has many ways to perform the division. So, here’s a fresh quote by Matz himself:

We have /, div, fdiv, and quo:
  /     - normal division, according to the class of operands
div    - integer division
fdiv   - float division
quo   - most accurate division (float if either operand is float, otherwise rational)
rdiv   - (which always results in rational) is obsolete.

Leave a Reply