357件ヒット
[1-100件を表示]
(0.056秒)
ライブラリ
- ビルトイン (185)
- bigdecimal (32)
- pathname (11)
- prime (44)
クラス
キーワード
- % (11)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Marshal フォーマット (11)
-
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Numeric (11)
- [] (21)
- bigdecimal (11)
-
bit
_ length (17) - format (11)
- frexp (11)
- getrlimit (11)
-
int
_ from _ prime _ division (11) - pow (22)
- power (14)
-
prime
_ division (33) - round (19)
-
ruby 1
. 6 feature (11) -
ruby 1
. 9 feature (11) - split (11)
- sprintf (11)
- sprintf フォーマット (11)
- sqrt (7)
- write (33)
検索結果
先頭5件
-
Integer
# **(other) -> Numeric (39143.0) -
算術演算子。冪(べき乗)を計算します。
...elf**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//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 (24143.0) -
算術演算子。冪(べき乗)を計算します。
...elf**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//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 (24043.0) -
算術演算子。冪(べき乗)を計算します。
...elf**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//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
# prime _ division(generator = Prime :: Generator23 . new) -> [[Integer , Integer]] (21208.0) -
自身を素因数分解した結果を返します。
...り、戻り値の各要素は2要素の配列 [n,e] であり、それぞれの内部配列の第1要素 n は self の素因数、第2要素は n**e が self を割り切る最大の自然数 e です。
@raise ZeroDivisionError self がゼロである場合に発生します。
@see Prime#prime... -
Integer
. sqrt(n) -> Integer (21173.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(......10**400) == 10**200 # => true
//}
Math.sqrt(n).floor と同等ですが、後者は浮動小数点数の精度の限界によって
真の値とは違う結果になることがあります。
//emlist[][ruby]{
Integer.sqrt(10**46) #=> 100000000000000000000000
Math.sqrt(10**46).floor #=> 999... -
Integer
# bit _ length -> Integer (21149.0) -
self を表すのに必要なビット数を返します。
...ま
す。2**n の場合は n+1 になります。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_l......# => 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
# [](nth) -> Integer (21109.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...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] }
# => 000101110110100000111000011110010100111100010111001
//}
n[i] は (n >> i) & 1 と等価なので、負のイ... -
Integer
# [](nth , len) -> Integer (21109.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...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] }
# => 000101110110100000111000011110010100111100010111001
//}
n[i] は (n >> i) & 1 と等価なので、負のイ... -
Integer
# [](range) -> Integer (21109.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...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] }
# => 000101110110100000111000011110010100111100010111001
//}
n[i] は (n >> i) & 1 と等価なので、負のイ... -
Integer
# [](nth) -> Integer (21107.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...かの数値
@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] }
# => 000101110110100000111000011110010100111100010111001
//}
n[i] は (n >> i) & 1 と等価なので、負のイン... -
BigDecimal
# **(n) -> BigDecimal (18106.0) -
self の n 乗を計算します。
...self の n 乗を計算します。
戻り値の有効桁数は self の有効桁数の n 倍以上になります。
@param n selfを other 乗する数を指定します。
@param prec 有効桁数を整数で指定します。
@see Integer#pow... -
BigDecimal
# power(n) -> BigDecimal (3006.0) -
self の n 乗を計算します。
...self の n 乗を計算します。
戻り値の有効桁数は self の有効桁数の n 倍以上になります。
@param n selfを other 乗する数を指定します。
@param prec 有効桁数を整数で指定します。
@see Integer#pow... -
BigDecimal
# power(n , prec) -> BigDecimal (3006.0) -
self の n 乗を計算します。
...self の n 乗を計算します。
戻り値の有効桁数は self の有効桁数の n 倍以上になります。
@param n selfを other 乗する数を指定します。
@param prec 有効桁数を整数で指定します。
@see Integer#pow...