Returns the largest number less than or equal to int
with a precision of ndigits
decimal digits (default: 0).
When the precision is negative, the returned value is an integer with at least ndigits.abs
trailing zeros.
Returns self
when ndigits
is zero or positive.
1.floor #=> 1 1.floor(2) #=> 1 18.floor(-1) #=> 10 (-18).floor(-1) #=> -20
Returns the remainder after dividing int
by numeric
.
x.remainder(y)
means x-y*(x/y).truncate
.
5.remainder(3) #=> 2 -5.remainder(3) #=> -2 5.remainder(-3) #=> 2 -5.remainder(-3) #=> -2 5.remainder(1.5) #=> 0.5
See Numeric#divmod
.
Returns the value as a rational.
1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns false.
Returns the value as a string.
Complex(2).to_s #=> "2+0i" Complex('-8/6').to_s #=> "-4/3+0i" Complex('1/2i').to_s #=> "0+1/2i" Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i" Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i"
Returns the value as an integer if possible (the imaginary part should be exactly zero).
Complex(1, 0).to_i #=> 1 Complex(1, 0.0).to_i # RangeError Complex(1, 2).to_i # RangeError
Returns the value as a float if possible (the imaginary part should be exactly zero).
Complex(1, 0).to_f #=> 1.0 Complex(1, 0.0).to_f # RangeError Complex(1, 2).to_f # RangeError
Returns the value as a rational if possible (the imaginary part should be exactly zero).
Complex(1, 0).to_r #=> (1/1) Complex(1, 0.0).to_r # RangeError Complex(1, 2).to_r # RangeError
See rationalize.
Returns zero as a complex.
Always returns the empty string.
Returns zero as a rational.
Returns the value as a complex.
Returns self.
Returns an array; [num, 0].
Returns an array; [num, 0].