rationalize

rat.rationalize â self
rat.rationalize(eps) â rational
Instance Public methods

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

r = Rational(5033165, 16777216)
r.rationalize                    #=> (5033165/16777216)
r.rationalize(Rational('0.01'))  #=> (3/10)
r.rationalize(Rational('0.1'))   #=> (1/3)
doc_ruby_on_rails
2015-05-01 04:14:17
Comments
Leave a Comment

Please login to continue.