るりまサーチ

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

別のキーワード

  1. bigdecimal/util to_d
  2. bigdecimal round
  3. bigdecimal div
  4. bigdecimal to_s
  5. bigdecimal ceil

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

BigDecimal#**(n) -> BigDecimal (39203.0)

self の n 乗を計算します。

self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。
self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。


@see Integer#pow

BigDecimal#power(n) -> BigDecimal (24103.0)

self の n 乗を計算します。

self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。
self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。


@see Integer#pow

BigDecimal#power(n, prec) -> BigDecimal (24103.0)

self の n 乗を計算します。

self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。
self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。


@see Integer#pow

BigDecimal#%(n) -> BigDecimal (21126.0)

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

...指定します。

//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
( x % 3).to_i # => 1
(-x % 3).to_i # => 2
( x % -3).to_i # => -2
(-x % -3).to_i # => -1
//}

戻り値は n と同じ符号になります。これは BigDecimal#remainder とは
異なる点に注意してく...

BigDecimal#modulo(n) -> BigDecimal (21126.0)

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

...指定します。

//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
( x % 3).to_i # => 1
(-x % 3).to_i # => 2
( x % -3).to_i # => -2
(-x % -3).to_i # => -1
//}

戻り値は n と同じ符号になります。これは BigDecimal#remainder とは
異なる点に注意してく...

絞り込み条件を変える

BigDecimal#remainder(n) -> BigDecimal (21125.0)

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

...//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
x.remainder(3).to_i # => 1
(-x).remainder(3).to_i # => -1
x.remainder(-3).to_i # => 1
(-x).remainder(-3).to_i # => -1
//}

戻り値は self と同じ符号になります。これは BigDecimal#% とは異な
る点に注...

BigDecimal#split -> [Integer, String, Integer, Integer] (21056.0)

BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。

...
BigDecimal
値を 0.xxxxxxx*10**n と表現したときに、
符号 (NaNのときは 0、それ以外は+1か-1になります)、
仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。

//emlist[][ruby]{
require "bigdecimal"
a = BigDecimal("3.14159265")
f...
..., x, y, z = a.split
//}

とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換することができます。

//emlist[][ruby]{
s = "0."+x
b = f*(s.to_f)*(y**z)
//}

@see BigDecimal#to_f...

Integer#**(other) -> Numeric (18142.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...

bigdecimal (6616.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...bigdecimal は浮動小数点数演算ライブラリです。
任意の精度で 10 進表現された浮動小数点数を扱えます。

//emlist[][ruby]{
require 'bigdecimal'
a = BigDecimal("0.123456789123456789")
b = BigDecimal("123456.78912345678", 40)
print a + b # => 0.123456912580245903456...
...に対し、BigDecimal では正確な値を得る事ができます。

//emlist[例1: 0.0001 を 10000 回足す場合。][ruby]{
sum = 0
for i in (1..10000)
sum = sum + 0.0001
end
print sum # => 0.9999999999999062
//}

//emlist[例2: 0.0001 を 10000 回足す場合。(BigDecimal)][ruby]{
requi...
...構造

BigDecimal
内部で浮動小数点は構造体(Real)で表現されます。
そのうち仮数部は unsigned long の配列 (以下の構造体要素 frac) で管理されます。
概念的には、以下のようになります。

<浮動小数点数> = 0.xxxxxxxxx * BASE ** n

ここ...

Integer#pow(other) -> Numeric (3042.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...

絞り込み条件を変える

<< 1 2 > >>