るりまサーチ

最速Rubyリファレンスマニュアル検索!
722件ヒット [1-100件を表示] (0.067秒)
トップページ > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:-[x] > クエリ:@[x] > クラス:Integer[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#-(other) -> Numeric (18126.0)

算術演算子。差を計算します。

...算術演算子。差を計算します。

@
param other 二項演算の右側の引数(対象)
@
return 計算結果

//emlist[][ruby]{
4 - 1 #=> 3
//}...

Integer#-@ -> Integer (12248.0)

単項演算子の - です。 self の符号を反転させたものを返します。

...単項演算子の - です。
self の符号を反転させたものを返します。

//emlist[][ruby]{
-
10 # => -10
-
-10 # => 10
//}...

Integer#[](nth) -> Integer (246.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...

@
param nth 何ビット目を指すかの数値
@
param len 何ビット分を返すか
@
param range 返すビットの範囲
@
return self[nth] は 1 か 0
@
return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@
return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1)...
...
@
return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@
return self[i..] は (n >> i) と同じ
@
return self[..j] は n & ((1 << (j + 1)) - 1) が 0 なら 0
@
return self[...j] は n & ((1 << j) - 1) が 0 なら 0
@
raise ArgumentError self[..j] で n & ((1 << (j + 1)) -...
...1) が 0 以外のとき
@
raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010

a = 9**15
50.downto(0) {|n| print a[n] }
# => 0001011101101000001110000111100101001111000...

Integer#[](nth, len) -> Integer (246.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...

@
param nth 何ビット目を指すかの数値
@
param len 何ビット分を返すか
@
param range 返すビットの範囲
@
return self[nth] は 1 か 0
@
return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@
return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1)...
...
@
return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@
return self[i..] は (n >> i) と同じ
@
return self[..j] は n & ((1 << (j + 1)) - 1) が 0 なら 0
@
return self[...j] は n & ((1 << j) - 1) が 0 なら 0
@
raise ArgumentError self[..j] で n & ((1 << (j + 1)) -...
...1) が 0 以外のとき
@
raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010

a = 9**15
50.downto(0) {|n| print a[n] }
# => 0001011101101000001110000111100101001111000...

Integer#[](range) -> Integer (246.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...

@
param nth 何ビット目を指すかの数値
@
param len 何ビット分を返すか
@
param range 返すビットの範囲
@
return self[nth] は 1 か 0
@
return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@
return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1)...
...
@
return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@
return self[i..] は (n >> i) と同じ
@
return self[..j] は n & ((1 << (j + 1)) - 1) が 0 なら 0
@
return self[...j] は n & ((1 << j) - 1) が 0 なら 0
@
raise ArgumentError self[..j] で n & ((1 << (j + 1)) -...
...1) が 0 以外のとき
@
raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010

a = 9**15
50.downto(0) {|n| print a[n] }
# => 0001011101101000001110000111100101001111000...

絞り込み条件を変える

Integer#**(other) -> Numeric (216.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...ます。
@
raise ArgumentError 計算結果が巨大になりすぎる場合に発生します。

//emlist[][ruby]{
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
//}


...
...算結果が巨大すぎるときは ArgumentError が発生します。

//emlist[計算結果が巨大すぎる例][ruby]{
p 100**9999999999999999999
# => exponent is too large (ArgumentError)
//}

判定の閾値は変わりえます。

@
see BigDecimal#power...

Integer#pow(other) -> Numeric (216.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...ます。
@
raise ArgumentError 計算結果が巨大になりすぎる場合に発生します。

//emlist[][ruby]{
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
//}


...
...算結果が巨大すぎるときは ArgumentError が発生します。

//emlist[計算結果が巨大すぎる例][ruby]{
p 100**9999999999999999999
# => exponent is too large (ArgumentError)
//}

判定の閾値は変わりえます。

@
see BigDecimal#power...

Integer#pow(other, modulo) -> Integer (216.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...ます。
@
raise ArgumentError 計算結果が巨大になりすぎる場合に発生します。

//emlist[][ruby]{
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
//}


...
...算結果が巨大すぎるときは ArgumentError が発生します。

//emlist[計算結果が巨大すぎる例][ruby]{
p 100**9999999999999999999
# => exponent is too large (ArgumentError)
//}

判定の閾値は変わりえます。

@
see BigDecimal#power...

Integer#**(other) -> Numeric (210.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...の数を指定した場合に発生します。

//emlist[][ruby]{
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
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

Integer#pow(other) -> Numeric (210.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...の数を指定した場合に発生します。

//emlist[][ruby]{
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
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

絞り込み条件を変える

Integer#pow(other, modulo) -> Integer (210.0)

算術演算子。冪(べき乗)を計算します。

...乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以外を指定した場...
...の数を指定した場合に発生します。

//emlist[][ruby]{
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
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

Integer#bit_length -> Integer (168.0)

self を表すのに必要なビット数を返します。

...(0 や
-
1 である)場合は 0 を返します。

//emlist[例: ceil(log2(int < 0 ? -int : int+1)) と同じ結果][ruby]{
(-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.b...
...it_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_length # => 13
(2**12+1...
...).bit_length # => 13
//}

@
see Integer#size...

Integer#remainder(other) -> Numeric (168.0)

self を other で割った余り r を返します。

...

@
param other self を割る数。

//emlist[][ruby]{
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#di...
...vmod, Integer#modulo, Numeric#modulo...
<< 1 2 3 ... > >>