Ruby Float to_r() method with example Read Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report Float to_r() is a float class method which return a rational form of the float value. Syntax: float.to_r() Parameter: float value as argument Return: Rational form representation of the float value. Example #1 : # Ruby code for to_r() method # Initializing values a = 2.0 b = 9.99991 # Printing result puts "Rational form of a : #{a.to_r}\n\n" puts "Rational Form of b : #{b.to_r}\n\n" Output : Rational form of a : 2/1 Rational Form of b : 21990034643427/2199023255552 Example #2 : # Ruby code for to_r() method # Initializing value a = 0.767 b = 2797999.011 # Printing result puts "Rational form of a : #{a.to_r}\n\n" puts "Rational Form of b : #{b.to_r}\n\n" Output : Rational form of a : 6908521828386341/9007199254740992 Rational Form of b : 375541070202667/134217728 Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about! Last Updated : 07 Jan, 2020 Like Article Save Article Previous Ruby | Float eql() method Next Ruby Float absolute() method with example Share your thoughts in the comments Add Your Comment Please Login to comment...