Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Float#numerator

flo.numerator → integer

Returns the numerator. The result is machine dependent.

Example
n = 0.3.numerator    #=> 5404319552844595
d = 0.3.denominator  #=> 18014398509481984
n.fdiv(d)            #=> 0.3

See also Float#denominator.

See also #next_float #phase #negative? #positive? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0