bigdecimal/math.rb e$B$Ne(B BigMath e$B$O!“MxMQ<T$,e(B include
e$B$7$F$D$+$&$3$H$rA0e(B
e$BDs$H$7$F$$$^$9$,!”$$+$7$J$3$H$G!"$=$l$J$i:G=i$+$i$=$N$h$&$K$7$F$$1$Pe(B
e$B$h$$$O$:$G$9!#K\Ev$O!"e(BBigMath
e$B$N%a%=%C%I$r%b%8%e!<%k4X?t$K$7$F$*$1$P!"e(B
Math e$BF1MM!"e(Binclude
e$B$7$F$b$7$J$/$F$b!"MxMQ<T$NH=CG$G$D$+$$J,$1$F$-$^$9!#e(B
BigMath e$B$N%a%=%C%I$O%b%8%e!<%k4X?t$K$7$?$i$$$$$H;W$$$^$9!#e(B
bigdecimal/util.rb e$B$Ke(B Integer#to_d e$B$,$"$j$^$;$s!#e(B
bigdecimal/util.rb e$B$Ne(B Float#to_d e$B$O!“e(BBigDecimal(self.to_s)
e$B$7$F$$$k$@e(B
e$B$1$G$9!#$o$6$H4E$/$7$F$$$k2DG=@-$b$”$j$=$&$G$9$,!"$b$C$H$A$c$s$H$9$k$3e(B
e$B$H$b$G$-$k$H;W$$$^$9!#=$@5$9$k$H!"$&$A$G$Oe(B Math::PI.to_d.to_f ==
Math::PI e$B$,@.$jN)$A$^$7$?!#e(B
Index: ext/bigdecimal/lib/bigdecimal/util.rb
— ext/bigdecimal/lib/bigdecimal/util.rb (revision 15420)
+++ ext/bigdecimal/lib/bigdecimal/util.rb (working copy)
@@ -15,8 +15,31 @@
class Float < Numeric
+
- unless defined?(decode)
- def decode
-
f, n = Math.frexp(self)
-
f = Math.ldexp(f, Float::MANT_DIG).to_i
-
n -= Float::MANT_DIG
-
return f, n
- end
- private :decode
- end
- def to_d
- f, n = decode
- f.to_s.to_d * Float::RADIX.to_s.to_d ** n
- end
+end
+
+class Integer < Numeric
- def to_d
BigDecimal(self.to_s)
end
end
Index: ext/bigdecimal/lib/bigdecimal/math.rb
===================================================================
— ext/bigdecimal/lib/bigdecimal/math.rb (revision 15420)
+++ ext/bigdecimal/lib/bigdecimal/math.rb (working copy)
@@ -30,6 +30,8 @@
module BigMath
- module_function
-
Computes the square root of x to the specified number of digits of
precision.