Fractional Numbers
Learn about fractional numbers in Ruby.
We'll cover the following
Consider some popular type castings that we’re already familiar with. One or another object may have one or more of the following methods:
-
.to_i
: This converts something to an integer. For example, it converts a string to a number. -
.to_s
: This converts something to a string. For example, it converts a number to a string. -
.to_f
: This converts something to a fraction. For example, it converts a string to a fraction.
Get hands-on with 1400+ tech skills courses.