The abstract class for integers. Its subclasses are Fixnum and Bignum. These two types of integers are automatically converted into one another according to their values. Integers can be treated as infinite bit strings for bit operations.
Returns 1 if the nth bit of the integer is set (with the LSB, or least significant bit, at position 0), otherwise returns 0.
self[nth]=bit is not an Integer method because the associated Numeric class is immutable.
Arithmetic operators that compute the sum, difference, product, quotient, remainder, and exponent, respectively.
Compares self with other and returns a positive integer if self is larger, 0 if the two are equal, and a negative integer if self is smaller.
Relational operators.
Bit operators that compute bitwise negation, logical OR, logical AND, and logical XOR, respectively.
Shift operators that shift only bits to the right or left, respectively.
The signed bit (MSB or most significant bit) is retained in a right shift.
Returns a 1-byte string corresponding to the numeric position in the character set. For example, 65.chr returns "A".
The integer must be within the range of 0 to 255. Calling this method with an out-of-range integer will throw a RangeError exception.
Iterates from self to min, decrementing by 1 each time. If self < min, does nothing.
Returns the "next" value of an integer.
Iteratively evaluates a block from self, incrementing by step, until limit is about to be surpassed. step can also be a negative number.
Throws an ArgumentError exception when step is set to 0.
Returns self.
Iterates self number of times, from 0 to self-1. If self is negative, does nothing.
Returns self.
Converts a value to a floating-point number (Float).
Converts an integer to a base-10 string expression.
If an argument is specified, it will be used as the base number for conversion. If a base outside the range of 2-36 is specified, an ArgumentError exception will be thrown.
p 10.to_s(2) # => "1010" p 10.to_s(8) # => "12" p 10.to_s(16) # => "a" p 35.to_s(36) # => "z"
Iterates from self to max, incrementing by 1 each time. If self > max, does nothing.
Returns self.