11件ヒット
[1-11件を表示]
(0.017秒)
検索結果
先頭1件
-
bigdecimal (19.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}
: truncate, round, ceil, floor
これらのメソッドは小数点からの相対位置を指定して桁数を決定します。
//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("6.66666666666666").round(12).to_s(10)
# => 0.6666666666 667e1
//}
=......mlist[pi.rb][ruby]{
#!/usr/local/bin/ruby
require "bigdecimal"
#
# Calculates 3.1415.... (the number of times that a circle's diameter
# will fit around the circle) using J. Machin's formula.
#
def big_pi(sig) # sig: Number of significant figures
exp = -sig
pi = BigDecimal("0")
two...