ライブラリ
- ビルトイン (71)
キーワード
- % (1)
- & (1)
- * (1)
- ** (1)
- + (1)
- - (1)
- -@ (1)
-
/ (1) - < (1)
- << (1)
- <= (1)
- <=> (1)
- == (1)
- === (1)
- > (1)
- >= (1)
- >> (1)
- [] (1)
- ^ (1)
- abs (1)
- allbits? (1)
- anybits? (1)
-
bit
_ length (1) - ceil (1)
- chr (2)
- denominator (1)
- digits (2)
- div (1)
- divmod (1)
- downto (2)
- even? (1)
- fdiv (1)
- floor (1)
- gcd (1)
- gcdlcm (1)
- inspect (2)
- integer? (1)
- lcm (1)
- magnitude (1)
- modulo (1)
- next (1)
- nobits? (1)
- numerator (1)
- odd? (1)
- ord (1)
- pow (2)
- pred (1)
- rationalize (2)
- remainder (1)
- round (1)
- size (1)
- succ (1)
- times (2)
-
to
_ f (1) -
to
_ i (1) -
to
_ int (1) -
to
_ r (1) -
to
_ s (2) - truncate (1)
- upto (2)
- | (1)
- ~ (1)
検索結果
先頭5件
-
Integer
# integer? -> true (69346.0) -
常に真を返します。
...常に真を返します。
例:
1.integer? # => true
1.0.integer? # => false... -
Integer
# gcd(n) -> Integer (51346.0) -
自身と整数 n の最大公約数を返します。
...# => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1
また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。
3.gcd(0) # => 3
0.gcd(-7) # => 7
@see Integer#lcm, Integer#gcdlcm... -
Integer
# gcdlcm(n) -> [Integer] (51346.0) -
自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。
...します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
例:
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]
@see Integer#gcd, Integer#lcm... -
Integer
# lcm(n) -> Integer (51346.0) -
自身と整数 n の最小公倍数を返します。
...# => 2
3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297
また、self や n が 0 だった場合は、0 を返します。
3.lcm(0) # => 0
0.lcm(-7) # => 0
@see Integer#gcd, Integer#gcdlcm... -
Integer
# upto(max) {|n| . . . } -> Integer (51346.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...ん。
@param max 数値
@return self を返します。
例:
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# next -> Integer (51331.0) -
self の次の整数を返します。
...self の次の整数を返します。
例:
1.next #=> 2
(-1).next #=> 0
1.succ #=> 2
(-1).succ #=> 0
@see Integer#pred... -
Integer
# succ -> Integer (51331.0) -
self の次の整数を返します。
...self の次の整数を返します。
例:
1.next #=> 2
(-1).next #=> 0
1.succ #=> 2
(-1).succ #=> 0
@see Integer#pred... -
Integer
# bit _ length -> Integer (51328.0) -
self を表すのに必要なビット数を返します。
...length # => 0
0.bit_length # => 0
1.bit_length # => 1
0xff.bit_length # => 8
0x100.bit_length # => 9
(2**12-1).bit_length # => 12
(2**12).bit_length # => 13
(2**12+1).bit_length # => 13
@see Integer#size... -
Integer
# denominator -> Integer (51328.0) -
分母(常に1)を返します。
...分母(常に1)を返します。
@return 分母を返します。
例:
10.denominator # => 1
-10.denominator # => 1
@see Integer#numerator... -
Integer
# numerator -> Integer (51328.0) -
分子(常に自身)を返します。
...分子(常に自身)を返します。
@return 分子を返します。
例:
10.numerator # => 10
-10.numerator # => -10
@see Integer#denominator... -
Integer
# pow(other , modulo) -> Integer (51328.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。... -
Integer
# pred -> Integer (51328.0) -
self から -1 した値を返します。
...self から -1 した値を返します。
1.pred #=> 0
(-1).pred #=> -2
@see Integer#next... -
Integer
# size -> Integer (51328.0) -
整数の実装上のサイズをバイト数で返します。
...整数の実装上のサイズをバイト数で返します。
例:
p 1.size
p 0x1_0000_0000.size
# => 4
8
@see Integer#bit_length... -
Integer
# abs -> Integer (51313.0) -
self の絶対値を返します。
self の絶対値を返します。
例:
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321 -
Integer
# digits -> [Integer] (51313.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
-10.digits # Math::DomainError: out of domain が発生
@return 位取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentEr... -
Integer
# digits(base) -> [Integer] (51313.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
-10.digits # Math::DomainError: out of domain が発生
@return 位取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentEr... -
Integer
# magnitude -> Integer (51313.0) -
self の絶対値を返します。
self の絶対値を返します。
例:
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321 -
Integer
# &(other) -> Integer (51310.0) -
ビット二項演算子。論理積を計算します。
ビット二項演算子。論理積を計算します。
@param other 数値
例:
1 & 1 # => 1
2 & 3 # => 2 -
Integer
# -@ -> Integer (51310.0) -
単項演算子の - です。 self の符号を反転させたものを返します。
単項演算子の - です。
self の符号を反転させたものを返します。
例:
- 10 # => -10
- -10 # => 10 -
Integer
# <<(bits) -> Integer (51310.0) -
シフト演算子。bits だけビットを左にシフトします。
シフト演算子。bits だけビットを左にシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2 -
Integer
# >>(bits) -> Integer (51310.0) -
シフト演算子。bits だけビットを右にシフトします。
シフト演算子。bits だけビットを右にシフトします。
右シフトは、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 >> 1) # => 0b10
p -1 >> 1 # => -1 -
Integer
# [](nth) -> Integer (51310.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@return 1 か 0
self[nth]=bit (つまりビットの修正) がないのは、Numeric 関連クラスが
immutable であるためです。
例:
a = 0b11001100101010
30.downto(0) do |n| print a[n] end
# => 0000000000000000011001100101010
a = 9**15
50.downto(0... -
Integer
# ^(other) -> Integer (51310.0) -
ビット二項演算子。排他的論理和を計算します。
ビット二項演算子。排他的論理和を計算します。
@param other 数値
例:
1 ^ 1 # => 0
2 ^ 3 # => 1 -
Integer
# ceil(ndigits = 0) -> Integer (51310.0) -
self と等しいかより大きな整数のうち最小のものを返します。
self と等しいかより大きな整数のうち最小のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}
@see Numeric#ceil -
Integer
# divmod(other) -> [Integer , Numeric] (51310.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし
て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
@param other self を割る数。
@see Numeric#divmod -
Integer
# floor(ndigits = 0) -> Integer (51310.0) -
self と等しいかより小さな整数のうち最大のものを返します。
self と等しいかより小さな整数のうち最大のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.floor # => 1
1.floor(2) # => 1
18.floor(-1) # => 10
(-18).floor(-1) # => -20
//}
@see Numeric#floor -
Integer
# ord -> Integer (51310.0) -
自身を返します。
自身を返します。
10.ord #=> 10
# String#ord
?a.ord #=> 97
@see String#ord -
Integer
# round(ndigits = 0 , half: :up) -> Integer (51310.0) -
self ともっとも近い整数を返します。
self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlist[][ruby]{
1.round # =... -
Integer
# truncate(ndigits = 0) -> Integer (51310.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
0 から self までの整数で、自身にもっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) #=> 10
(-18).truncate(-1) #=> -10
//}
@see Numeric#truncate -
Integer
# |(other) -> Integer (51310.0) -
ビット二項演算子。論理和を計算します。
ビット二項演算子。論理和を計算します。
@param other 数値
例:
1 | 1 # => 1
2 | 3 # => 3 -
Integer
# ~ -> Integer (51310.0) -
ビット演算子。否定を計算します。
ビット演算子。否定を計算します。
例:
~1 # => -2
~3 # => -4
~-4 # => 3 -
Integer
# upto(max) -> Enumerator (51046.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...ん。
@param max 数値
@return self を返します。
例:
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# allbits?(mask) -> bool (51043.0) -
self & mask の全てのビットが 1 なら true を返します。
...mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.allbits?(42) # => true
0b1010_1010.allbits?(0b1000_0010) # => true
0b1010_1010.allbits?(0b1000_0001) # => false
0b1000_0010.allbits?(0b1010_1010) # => false
//}
@see Integer#anybits?
@see Integer#nobits?... -
Integer
# anybits? -> bool (51043.0) -
self & mask のいずれかのビットが 1 なら true を返します。
...m mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.anybits?(42) # => true
0b1010_1010.anybits?(0b1000_0010) # => true
0b1010_1010.anybits?(0b1000_0001) # => true
0b1000_0010.anybits?(0b0010_1100) # => false
//}
@see Integer#allbits?
@see Integer#nobits?... -
Integer
# downto(min) -> Enumerator (51043.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
例:
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# downto(min) {|n| . . . } -> self (51043.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
例:
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# nobits? -> bool (51043.0) -
self & mask のすべてのビットが 0 なら true を返します。
...am mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.nobits?(42) # => false
0b1010_1010.nobits?(0b1000_0010) # => false
0b1010_1010.nobits?(0b1000_0001) # => false
0b0100_0101.nobits?(0b1010_1010) # => true
//}
@see Integer#allbits?
@see Integer#anybits?... -
Integer
# remainder(other) -> Numeric (51043.0) -
self を other で割った余り r を返します。
...。
例:
5.remainder(3) # => 2
-5.remainder(3) # => -2
5.remainder(-3) # => 2
-5.remainder(-3) # => -2
-1234567890987654321.remainder(13731) # => -6966
-1234567890987654321.remainder(13731.24) # => -9906.22531493148
@see Integer#divmod, Integer#modulo, Numeric#modulo... -
Integer
# times -> Enumerator (51043.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...数値が渡されます。
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# times {|n| . . . } -> self (51043.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...数値が渡されます。
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# **(other) -> Numeric (51028.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。... -
Integer
# pow(other) -> Numeric (51028.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。... -
Integer
# / (other) -> Numeric (51025.0) -
算術演算子。商を計算します。
...計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
4 / 2 # => 2
5 / 2 # => 2
-4 / 2 # => -2
-4.div(2) # => -2
begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}
@see Integer#fdiv, Numeric#div, Numeric#fdiv... -
Integer
# div(other) -> Numeric (51025.0) -
算術演算子。商を計算します。
...計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
4 / 2 # => 2
5 / 2 # => 2
-4 / 2 # => -2
-4.div(2) # => -2
begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}
@see Integer#fdiv, Numeric#div, Numeric#fdiv... -
Integer
# fdiv(other) -> Numeric (51025.0) -
self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。
...です。
その場合も成分は Float になります。
@param other self を割る数を指定します。
@see Numeric#quo, Numeric#div, Integer#div... -
Integer
# %(other) -> Numeric (51007.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
例:
# 剰余
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# *(other) -> Numeric (51007.0) -
算術演算子。積を計算します。
算術演算子。積を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 積
2 * 3 # => 6 -
Integer
# +(other) -> Numeric (51007.0) -
算術演算子。和を計算します。
算術演算子。和を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 和
3 + 4 # => 7 -
Integer
# -(other) -> Numeric (51007.0) -
算術演算子。差を計算します。
算術演算子。差を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 差
4 - 1 #=> 3 -
Integer
# <(other) -> bool (51007.0) -
比較演算子。数値として小さいか判定します。
比較演算子。数値として小さいか判定します。
@param other 比較対象の数値
@return self よりも other が大きい場合 true を返します。
そうでなければ false を返します。
例:
1 < 1 # => false
1 < 2 # => true -
Integer
# <=(other) -> bool (51007.0) -
比較演算子。数値として等しいまたは小さいか判定します。
比較演算子。数値として等しいまたは小さいか判定します。
@param other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (51007.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時
に-1、比較できない時に nil を返します。
@param other 比較対象の数値
@return -1 か 0 か 1 か nil のいずれか
//emlist[][ruby]{
1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # => 1
2 <=> '' # => nil
//} -
Integer
# ==(other) -> bool (51007.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 == 2 # => false
1 == 1.0 # => true -
Integer
# ===(other) -> bool (51007.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 == 2 # => false
1 == 1.0 # => true -
Integer
# >(other) -> bool (51007.0) -
比較演算子。数値として大きいか判定します。
比較演算子。数値として大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合 true を返します。
そうでなければ false を返します。
例:
1 > 0 # => true
1 > 1 # => false -
Integer
# >=(other) -> bool (51007.0) -
比較演算子。数値として等しいまたは大きいか判定します。
比較演算子。数値として等しいまたは大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 >= 0 # => true
1 >= 1 # => true
1 >= 2 # => false -
Integer
# chr -> String (51007.0) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p ... -
Integer
# chr(encoding) -> String (51007.0) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p ... -
Integer
# even? -> bool (51007.0) -
自身が偶数であれば真を返します。 そうでない場合は偽を返します。
自身が偶数であれば真を返します。
そうでない場合は偽を返します。
例:
10.even? # => true
5.even? # => false -
Integer
# inspect -> String (51007.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。 -
Integer
# inspect(base) -> String (51007.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。 -
Integer
# modulo(other) -> Numeric (51007.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
例:
# 剰余
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# odd? -> bool (51007.0) -
自身が奇数であれば真を返します。 そうでない場合は偽を返します。
自身が奇数であれば真を返します。
そうでない場合は偽を返します。
例:
5.odd? # => true
10.odd? # => false -
Integer
# rationalize -> Rational (51007.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
例:
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1) -
Integer
# rationalize(eps) -> Rational (51007.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
例:
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1) -
Integer
# to _ f -> Float (51007.0) -
self を浮動小数点数(Float)に変換します。
self を浮動小数点数(Float)に変換します。
self が Float の範囲に収まらない場合、Float::INFINITY を返します。
//emlist[][ruby]{
1.to_f # => 1.0
(Float::MAX.to_i * 2).to_f # => Infinity
(-Float::MAX.to_i * 2).to_f # => -Infinity
//} -
Integer
# to _ i -> self (51007.0) -
self を返します。
self を返します。
例:
10.to_i # => 10 -
Integer
# to _ int -> self (51007.0) -
self を返します。
self を返します。
例:
10.to_i # => 10 -
Integer
# to _ r -> Rational (51007.0) -
自身を Rational に変換します。
自身を Rational に変換します。
例:
1.to_r # => (1/1)
(1<<64).to_r # => (18446744073709551616/1) -
Integer
# to _ s -> String (51007.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。 -
Integer
# to _ s(base) -> String (51007.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。