method

rationalize

Importance_1
rationalize(p1 = v1) public

Returns a simpler approximation of the value if an optional argument eps is given (rat-|eps| <= result <= rat+|eps|), self otherwise.

For example:

r = Rational(5033165, 16777216)
r.rationalize                    #=> (5033165/16777216)
r.rationalize(Rational('0.01'))  #=> (3/10)
r.rationalize(Rational('0.1'))   #=> (1/3)
Show source
Register or log in to add new notes.