method
rationalize
v2_2_9 -
Show latest stable
- Class:
Complex
rationalize(p1 = v1)public
Returns the value as a rational if possible (the imaginary part should be exactly zero).
Complex(1.0/3, 0).rationalize #=> (1/3) Complex(1, 0.0).rationalize # RangeError Complex(1, 2).rationalize # RangeError
See to_r.