Results for: "pstore"

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)

Returns self; intended for compatibility to character literals in Ruby 1.9.

Returns self (which is already an Integer).

Returns the value as a rational.

1.to_r        #=> (1/1)
(1<<64).to_r  #=> (18446744073709551616/1)

Returns a new Complex object formed from the arguments, each of which must be an instance of Numeric, or an instance of one of its subclasses: Complex, Float, Integer, Rational; see Rectangular Coordinates:

Complex.rect(3)             # => (3+0i)
Complex.rect(3, Math::PI)   # => (3+3.141592653589793i)
Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)

Complex.rectangular is an alias for Complex.rect.

Returns a new Complex object formed from the arguments, each of which must be an instance of Numeric, or an instance of one of its subclasses: Complex, Float, Integer, Rational; see Rectangular Coordinates:

Complex.rect(3)             # => (3+0i)
Complex.rect(3, Math::PI)   # => (3+3.141592653589793i)
Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)

Complex.rectangular is an alias for Complex.rect.

Returns the real value for self:

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

If self was created with polar coordinates, the returned value is computed, and may be inexact:

Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.

Returns the array [self.real, self.imag]:

Complex.rect(1, 2).rect # => [1, 2]

See Rectangular Coordinates.

If self was created with polar coordinates, the returned value is computed, and may be inexact:

Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]

Complex#rectangular is an alias for Complex#rect.

Returns a new Complex object formed from the arguments, each of which must be an instance of Numeric, or an instance of one of its subclasses: Complex, Float, Integer, Rational; see Rectangular Coordinates:

Complex.rect(3)             # => (3+0i)
Complex.rect(3, Math::PI)   # => (3+3.141592653589793i)
Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)

Complex.rectangular is an alias for Complex.rect.

Returns false; for compatibility with Numeric#real?.

Returns a string representation of self:

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 of self.real as an Integer, if possible:

Complex(1, 0).to_i              # => 1
Complex(1, Rational(0, 1)).to_i # => 1

Raises RangeError if self.imag is not exactly zero (either Integer(0) or Rational(0, n)).

Returns the value of self.real as a Float, if possible:

Complex(1, 0).to_f              # => 1.0
Complex(1, Rational(0, 1)).to_f # => 1.0

Raises RangeError if self.imag is not exactly zero (either Integer(0) or Rational(0, n)).

Returns the value of self.real as a Rational, if possible:

Complex(1, 0).to_r              # => (1/1)
Complex(1, Rational(0, 1)).to_r # => (1/1)

Raises RangeError if self.imag is not exactly zero (either Integer(0) or Rational(0, n)).

Related: Complex#rationalize.

Returns self.

Returns the value as a BigDecimal.

The precision parameter is required for a rational complex number. This parameter is used to determine the number of significant digits for the result.

require 'bigdecimal'
require 'bigdecimal/util'

Complex(0.1234567, 0).to_d(4)   # => 0.1235e0
Complex(Rational(22, 7), 0).to_d(3)   # => 0.314e1

See also Kernel.BigDecimal.

Returns zero as a Complex:

nil.to_c # => (0+0i)

Returns nil represented as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

nil.to_d   # => 0.0

Always returns zero.

nil.to_i   #=> 0

Always returns zero.

nil.to_f   #=> 0.0

Returns an empty String:

nil.to_s # => ""

Returns an empty Array.

nil.to_a # => []

Returns an empty Hash.

nil.to_h   #=> {}

Returns zero as a Rational:

nil.to_r # => (0/1)

Returns self as a Complex object.

Search took: 4ms  ·  Total Results: 3855