るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.015秒)

別のキーワード

  1. _builtin **
  2. matrix **
  3. bigdecimal **
  4. rational **
  5. bn **

キーワード

検索結果

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

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

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

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

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

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

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

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

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

Integer#bit_length -> Integer (136.0)

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

...# => 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.sqrt(n) -> Integer (82.0)

非負整数 n の整数の平方根を返します。すなわち n の平方根以下の 最大の非負整数を返します。

...Integer ではない場合は、最初に Integer に変換されます。
@raise Math::DomainError n が負の整数の時に発生します。

//emlist[][ruby]{
Integer
.sqrt(0) # => 0
Integer
.sqrt(1) # => 1
Integer
.sqrt(24) # => 4
Integer
.sqrt(25) # => 5
Integer
.sqrt(...
....floor と同等ですが、後者は浮動小数点数の精度の限界によって
真の値とは違う結果になることがあります。

//emlist[][ruby]{
Integer
.sqrt(10**46) #=> 100000000000000000000000
Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
//}


@see Math.#sqrt...

絞り込み条件を変える

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

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

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

@param nth 何ビット目を指すかの数値
@return 1 か 0

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

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