Results for: "match"

Returns a 1-character string containing the character represented by the value of self, according to the given encoding.

65.chr                   # => "A"
0..chr                   # => "\x00"
255.chr                  # => "\xFF"
string = 255.chr(Encoding::UTF_8)
string.encoding          # => Encoding::UTF_8

Raises an exception if self is negative.

Related: Integer#ord.

Returns self truncated (toward zero) to a precision of ndigits decimal digits.

When ndigits is negative, the returned value has at least ndigits.abs trailing zeros:

555.truncate(-1)  # => 550
555.truncate(-2)  # => 500
-555.truncate(-2) # => -500

Returns self when ndigits is zero or positive.

555.truncate     # => 555
555.truncate(50) # => 555

Related: Integer#round.

Returns the remainder after dividing self by other.

Examples:

11.remainder(4)              # => 3
11.remainder(-4)             # => 3
-11.remainder(4)             # => -3
-11.remainder(-4)            # => -3

12.remainder(4)              # => 0
12.remainder(-4)             # => 0
-12.remainder(4)             # => 0
-12.remainder(-4)            # => 0

13.remainder(4.0)            # => 1.0
13.remainder(Rational(4, 1)) # => (1/1)
No documentation available

Returns self.

Returns 1.

Returns the value as a rational. The optional argument eps is always ignored.

Returns the imaginary part.

Complex(7).imaginary      #=> 0
Complex(9, -4).imaginary  #=> -4

Returns the imaginary part.

Complex(7).imaginary      #=> 0
Complex(9, -4).imaginary  #=> -4

Returns the absolute part of its polar form.

Complex(-1).abs         #=> 1
Complex(3.0, -4.0).abs  #=> 5.0

Returns the complex conjugate.

Complex(1, 2).conjugate  #=> (1-2i)

Returns the numerator.

    1   2       3+4i  <-  numerator
    - + -i  ->  ----
    2   3        6    <-  denominator

c = Complex('1/2+2/3i')  #=> ((1/2)+(2/3)*i)
n = c.numerator          #=> (3+4i)
d = c.denominator        #=> 6
n / d                    #=> ((1/2)+(2/3)*i)
Complex(Rational(n.real, d), Rational(n.imag, d))
                         #=> ((1/2)+(2/3)*i)

See denominator.

Returns the denominator (lcm of both denominator - real and imag).

See numerator.

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.

Returns zero as a rational. The optional argument eps is always ignored.

Returns zero.

Returns zero.

Returns self.

Returns the remainder after dividing self by other.

Of the Core and Standard Library classes, only Float and Rational use this implementation.

Examples:

11.0.remainder(4)              # => 3.0
11.0.remainder(-4)             # => 3.0
-11.0.remainder(4)             # => -3.0
-11.0.remainder(-4)            # => -3.0

12.0.remainder(4)              # => 0.0
12.0.remainder(-4)             # => 0.0
-12.0.remainder(4)             # => -0.0
-12.0.remainder(-4)            # => -0.0

13.0.remainder(4.0)            # => 1.0
13.0.remainder(Rational(4, 1)) # => 1.0

Rational(13, 1).remainder(4)   # => (1/1)
Rational(13, 1).remainder(-4)  # => (1/1)
Rational(-13, 1).remainder(4)  # => (-1/1)
Rational(-13, 1).remainder(-4) # => (-1/1)

Returns the absolute value of self.

12.abs        #=> 12
(-34.56).abs  #=> 34.56
-34.56.abs    #=> 34.56

Numeric#magnitude is an alias for Numeric#abs.

Returns self truncated (toward zero) to a precision of digits decimal digits.

Numeric implements this by converting self to a Float and invoking Float#truncate.

Returns true if self is less than 0, false otherwise.

Returns the numerator.

Returns the denominator (always positive).

Returns a string containing the first character of self:

s = 'foo' # => "foo"
s.chr     # => "f"
Search took: 4ms  ·  Total Results: 1813