- 155 名前:デフォルトの名無しさん mailto:sage [2009/09/01(火) 00:24:29 ]
- -20以下くらいから誤差が大きくなって、正しく計算できてないようです
require 'bigdecimal' require 'bigdecimal/math' module BigMath; extend BigMath end n = -5 puts BigMath.exp(BigDecimal(n.to_s),10).to_s, BigDecimal(Math.exp(n).to_s).to_s # => 0.673794699908546709664220227128330426308743E-2 # => 0.673794699908547E-2 n = -40 puts BigMath.exp(BigDecimal(n.to_s),10).to_s, BigDecimal(Math.exp(n).to_s).to_s # => 0.148254074963145840156087212163166213816119E-7 # => 0.424835425529159E-17
|

|