176件ヒット
[1-100件を表示]
(0.020秒)
種類
- インスタンスメソッド (110)
- モジュール関数 (44)
- ライブラリ (11)
- 文書 (11)
ライブラリ
- ビルトイン (154)
クラス
-
Enumerator
:: Lazy (44) - Integer (33)
- Rational (11)
- String (11)
モジュール
- Enumerable (11)
- Kernel (22)
- Math (22)
検索結果
先頭5件
-
Integer
# **(other) -> Numeric (18166.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 (3066.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 (3066.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... -
Rational
# to _ f -> Float (159.0) -
自身の値を最も良く表現する Float に変換します。
...自身の値を最も良く表現する Float に変換します。
絶対値が極端に小さい、または大きい場合にはゼロや無限大が返ることがあります。
@return Float を返します。
//emlist[例][ruby]{
Rational(2).to_f # => 2.0
Rational(9, 4).to_f......# => 2.25
Rational(-3, 4).to_f # => -0.75
Rational(20, 3).to_f # => 6.666666666666667
Rational(1, 10**1000).to_f # => 0.0
Rational(-1, 10**1000).to_f # => -0.0
Rational(10**1000).to_f # => Infinity
Rational(-10**1000).to_f # => -Infinity
//}... -
bigdecimal (144.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...decimal"
BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity
BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
//}
無限大を表す BigDecimal オブジェクトを作成する場合、
Kernel.#BigDecimal の引数に "Infinity" や "-Infinity" を指定して
ください。(大文字小文......下の構造体要素 frac) で管理されます。
概念的には、以下のようになります。
<浮動小数点数> = 0.xxxxxxxxx * BASE ** n
ここで、x は仮数部を表す数字、BASE は基数 (10 進表現なら 10)、
n は指数部を表す整数値です。BASEが大きい......といった関数が使用できるようになります。
使用方法など、詳細は bigdecimal/math を参照して下さい。 その他、Float との相互変換などの
メソッドが bigdecimal/util でサポートされています。利用するには
//emlist[][ruby]{
require "big... -
Math
. # log(x) -> Float (120.0) -
x の対数(logarithm)を返します。
...x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeErr......らかに負の数を指定した場合に発生します。
//emlist[例][ruby]{
Math.log(0) # => -Infinity
Math.log(1) # => 0.0
Math.log(Math::E) # => 1.0
Math.log(Math::E**3) # => 3.0
Math.log(12, 3) # => 2.2618595071429146
//}
@see Math.#log2, Math.#log10, Math.#exp... -
Math
. # log(x , b) -> Float (120.0) -
x の対数(logarithm)を返します。
...x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeErr......らかに負の数を指定した場合に発生します。
//emlist[例][ruby]{
Math.log(0) # => -Infinity
Math.log(1) # => 0.0
Math.log(Math::E) # => 1.0
Math.log(Math::E**3) # => 3.0
Math.log(12, 3) # => 2.2618595071429146
//}
@see Math.#log2, Math.#log10, Math.#exp... -
Enumerable
# lazy -> Enumerator :: Lazy (48.0) -
自身を lazy な Enumerator に変換したものを返します。
...タゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の組) を
列挙するプログラムです。
//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|... -
Kernel
. # format(format , *arg) -> String (42.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
...し、Float::INFINITY、Float::NAN はそれぞれ 'Inf'、'NaN' になります。詳しくは 40650 を参照してください。
//emlist[][ruby]{
p sprintf("%a", -0.0) # => "-0x0p+0"
p sprintf("%a", 729.0/10) # => "0x1.239999999999ap+6"
p sprintf("%a", Float::INFINITY) # => "......sprintf("%f", 10.1) #=> "10.100000"
p sprintf("%e", 10.1) #=> "1.010000e+01"
p sprintf("%g", 10.1) #=> "10.1"
p sprintf("%g", 10 ** 6) #=> "1e+06"
p sprintf("%g", 10 ** -5) #=> "1e-05"
//}
精度の省略値は 6 です。
無限大、NaN(Not a Number) に対する出力は以下のとおり... -
Kernel
. # sprintf(format , *arg) -> String (42.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
...し、Float::INFINITY、Float::NAN はそれぞれ 'Inf'、'NaN' になります。詳しくは 40650 を参照してください。
//emlist[][ruby]{
p sprintf("%a", -0.0) # => "-0x0p+0"
p sprintf("%a", 729.0/10) # => "0x1.239999999999ap+6"
p sprintf("%a", Float::INFINITY) # => "......sprintf("%f", 10.1) #=> "10.100000"
p sprintf("%e", 10.1) #=> "1.010000e+01"
p sprintf("%g", 10.1) #=> "10.1"
p sprintf("%g", 10 ** 6) #=> "1e+06"
p sprintf("%g", 10 ** -5) #=> "1e-05"
//}
精度の省略値は 6 です。
無限大、NaN(Not a Number) に対する出力は以下のとおり...