Results for: "pstore"

Returns the value of int as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

42.to_d   # => 0.42e2

See also BigDecimal::new.

Returns a string containing the place-value representation of self in radix base (in 2..36).

12345.to_s               # => "12345"
12345.to_s(2)            # => "11000000111001"
12345.to_s(8)            # => "30071"
12345.to_s(10)           # => "12345"
12345.to_s(16)           # => "3039"
12345.to_s(36)           # => "9ix"
78546939656932.to_s(36)  # => "rubyrules"

Raises an exception if base is out of range.

Integer#inspect is an alias for Integer#to_s.

Calls the given block with each integer value from self up to limit; returns self:

a = []
5.upto(10) {|i| a << i }              # => 5
a                                     # => [5, 6, 7, 8, 9, 10]
a = []
-5.upto(0) {|i| a << i }              # => -5
a                                     # => [-5, -4, -3, -2, -1, 0]
5.upto(4) {|i| fail 'Cannot happen' } # => 5

With no block given, returns an Enumerator.

Calls the given block with each integer value from self down to limit; returns self:

a = []
10.downto(5) {|i| a << i }              # => 10
a                                       # => [10, 9, 8, 7, 6, 5]
a = []
0.downto(-5) {|i| a << i }              # => 0
a                                       # => [0, -1, -2, -3, -4, -5]
4.downto(5) {|i| fail 'Cannot happen' } # => 4

With no block given, returns an Enumerator.

Returns the predecessor of self (equivalent to self - 1):

1.pred  #=> 0
-1.pred #=> -2

Related: Integer#succ (successor value).

Converts self to a Float:

1.to_f  # => 1.0
-1.to_f # => -1.0

If the value of self does not fit in a Float, the result is infinity:

(10**400).to_f  # => Infinity
(-10**400).to_f # => -Infinity

Returns the largest number less than or equal to self with a precision of ndigits decimal digits.

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

555.floor(-1)  # => 550
555.floor(-2)  # => 500
-555.floor(-2) # => -600
555.floor(-3)  # => 0

Returns self when ndigits is zero or positive.

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

Related: Integer#ceil.

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 the int itself.

97.ord   #=> 97

This method is intended for compatibility to character literals in Ruby 1.9.

For example, ?a.ord returns 97 both in 1.8 and 1.9.

Since int is already an Integer, returns self.

to_int is an alias for to_i.

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 the real part.

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

Returns an array; [cmp.real, cmp.imag].

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

Returns a complex object which denotes the given rectangular form.

Complex.rectangular(1, 2)  #=> (1+2i)

Returns false, even if the complex number has no imaginary part.

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 self.

Complex(2).to_c      #=> (2+0i)
Complex(-8, 6).to_c  #=> (-8+6i)

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 BigDecimal::new.

Returns zero as a complex.

Returns nil represented as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

nil.to_d   # => 0.0
Search took: 2ms  ·  Total Results: 3094