別のキーワード
種類
- インスタンスメソッド (300)
- 特異メソッド (2)
キーワード
- % (3)
- & (3)
- * (3)
- ** (3)
- + (3)
- -@ (3)
-
/ (2) - < (3)
- << (3)
- <= (3)
- <=> (3)
- == (3)
- === (3)
- > (3)
- >= (3)
- >> (3)
- [] (3)
- ^ (3)
- abs (3)
- allbits? (2)
- anybits? (2)
-
bit
_ length (3) - ceil (6)
- chr (12)
- denominator (6)
- digits (6)
- div (3)
- divmod (3)
- downto (12)
- even? (6)
- fdiv (3)
- floor (6)
- gcd (6)
- gcdlcm (6)
- inspect (6)
- integer? (6)
- lcm (6)
- magnitude (3)
- modulo (3)
- next (6)
- nobits? (2)
- numerator (6)
- odd? (6)
- ord (6)
- pow (4)
- pred (6)
- rationalize (12)
- remainder (3)
- round (6)
- size (3)
- sqrt (2)
- succ (6)
- times (12)
-
to
_ f (3) -
to
_ i (6) -
to
_ int (6) -
to
_ r (6) -
to
_ s (12) - truncate (6)
- upto (12)
- | (3)
- ~ (3)
検索結果
先頭5件
-
Integer
# -(other) -> Numeric (18109.0) -
算術演算子。差を計算します。
...算術演算子。差を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 差
4 - 1 #=> 3... -
Integer
# -@ -> Integer (6143.0) -
単項演算子の - です。 self の符号を反転させたものを返します。
...単項演算子の - です。
self の符号を反転させたものを返します。
例:
- 10 # => -10
- -10 # => 10... -
Integer
# **(other) -> Numeric (163.0) -
算術演算子。冪(べき乗)を計算します。
...pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
例:
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3,......8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
@see BigDecimal#power... -
Integer
# pow(other) -> Numeric (163.0) -
算術演算子。冪(べき乗)を計算します。
...pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
例:
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3,......8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
@see BigDecimal#power... -
Integer
# pow(other , modulo) -> Integer (163.0) -
算術演算子。冪(べき乗)を計算します。
...pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
例:
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3,......8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
@see BigDecimal#power... -
Integer
# bit _ length -> Integer (157.0) -
self を表すのに必要なビット数を返します。
...0 や
-1 である)場合は 0 を返します。
例: ceil(log2(int < 0 ? -int : int+1)) と同じ結果
(-2**12-1).bit_length # => 13
(-2**12).bit_length # => 12
(-2**12+1).bit_length # => 12
-0x101.bit_length # => 9
-0x100.bit_length # => 8
-0xff.......bit_length # => 8
-2.bit_length # => 1
-1.bit_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_lengt... -
Integer
# remainder(other) -> Numeric (151.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
# chr -> String (141.0) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
...コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<E......# => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p 12354.chr Encoding::EUC_JP
# => RangeError: invalid codepoint 0x3042 in EUC-JP
p 12354.chr Encoding::ASCII_8BIT
# => RangeError: 12354 out of char range
p (2**32).chr
# => RangeError: bignum out of char range
@param... -
Integer
# chr(encoding) -> String (141.0) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
...コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<E......# => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p 12354.chr Encoding::EUC_JP
# => RangeError: invalid codepoint 0x3042 in EUC-JP
p 12354.chr Encoding::ASCII_8BIT
# => RangeError: 12354 out of char range
p (2**32).chr
# => RangeError: bignum out of char range
@param... -
Integer
# %(other) -> Numeric (139.0) -
算術演算子。剰余を計算します。
...算術演算子。剰余を計算します。
例:
# 剰余
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
@param other 二項演算の右側の引数(対象)
@return 計算結果... -
Integer
# modulo(other) -> Numeric (139.0) -
算術演算子。剰余を計算します。
...算術演算子。剰余を計算します。
例:
# 剰余
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
@param other 二項演算の右側の引数(対象)
@return 計算結果... -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (132.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
...、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
# round(ndigits = 0 , half: :up) -> Integer (127.0) -
self ともっとも近い整数を返します。
...d(-1) # => 20
(-15).round(-1) #=> -20
25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -3......0
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@see Numeric#round... -
Integer
# round(ndigits = 0 , half: :up) -> Integer | Float (127.0) -
self ともっとも近い整数を返します。
...合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の値の......d(-1) # => 20
(-15).round(-1) #=> -20
25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -3......0
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@see Numeric#round... -
Integer
# pred -> Integer (125.0) -
self から -1 した値を返します。
...self から -1 した値を返します。
1.pred #=> 0
(-1).pred #=> -2
@see Integer#next... -
Integer
# <<(bits) -> Integer (115.0) -
シフト演算子。bits だけビットを左にシフトします。
...ビットを左にシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2... -
Integer
# >>(bits) -> Integer (115.0) -
シフト演算子。bits だけビットを右にシフトします。
...します。
右シフトは、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 >> 1) # => 0b10
p -1 >> 1 # => -1... -
Integer
# abs -> Integer (115.0) -
self の絶対値を返します。
...self の絶対値を返します。
例:
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321... -
Integer
# inspect -> String (115.0) -
整数を 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 (115.0) -
整数を 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
# magnitude -> Integer (115.0) -
self の絶対値を返します。
...self の絶対値を返します。
例:
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321... -
Integer
# numerator -> Integer (115.0) -
分子(常に自身)を返します。
...分子(常に自身)を返します。
@return 分子を返します。
例:
10.numerator # => 10
-10.numerator # => -10
@see Integer#denominator... -
Integer
# to _ s -> String (115.0) -
整数を 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 (115.0) -
整数を 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
# ~ -> Integer (115.0) -
ビット演算子。否定を計算します。
...ビット演算子。否定を計算します。
例:
~1 # => -2
~3 # => -4
~-4 # => 3... -
Integer
# ceil(ndigits = 0) -> Integer (109.0) -
self と等しいかより大きな整数のうち最小のものを返します。
...数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}
@see Numeric#ceil... -
Integer
# ceil(ndigits = 0) -> Integer | Float (109.0) -
self と等しいかより大きな整数のうち最小のものを返します。
...負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1.0
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}
@see Numeric#ceil... -
Integer
# denominator -> Integer (109.0) -
分母(常に1)を返します。
...分母(常に1)を返します。
@return 分母を返します。
例:
10.denominator # => 1
-10.denominator # => 1
@see Integer#numerator... -
Integer
# digits -> [Integer] (109.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
...digits(16) # => [0, 1]
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
-10.digits # Math::DomainError: out of domain が発生
@return 位取り記数法で表した時の数値の配列
@param base 基数となる... -
Integer
# digits(base) -> [Integer] (109.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
...digits(16) # => [0, 1]
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
-10.digits # Math::DomainError: out of domain が発生
@return 位取り記数法で表した時の数値の配列
@param base 基数となる...