summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 16:59:09 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 16:59:09 +0000
commit1db209763a70b825db775e684ef3a21a6b5b9757 (patch)
treedb1a55fcd1cdbd6a124f72428ecb9405616c8c4f
parente337c7f9793ae9fc883d7a86f5954c3ba83566dc (diff)
* ext/bigdecimal/bigdecimal.c (BigDecimal_power): use rb_dbl2big
to convert a double value to a Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/bigdecimal/bigdecimal.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f9fa1e7..866a4ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jun 01 01:50:00 2013 Kenta Murata <mrkn@mrkn.jp>
+
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_power): use rb_dbl2big
+ to convert a double value to a Bignum.
+
Sat Jun 1 00:19:50 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (calc_hbase): Make hbase the maximum power of base
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 06b3886..2a0aea8 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2183,7 +2183,12 @@ retry:
case T_FLOAT:
d = RFLOAT_VALUE(vexp);
if (d == round(d)) {
- vexp = LL2NUM((LONG_LONG)round(d));
+ if (FIXABLE(d)) {
+ vexp = LONG2FIX((long)d);
+ }
+ else {
+ vexp = rb_dbl2big(d);
+ }
goto retry;
}
exp = GetVpValueWithPrec(vexp, DBL_DIG+1, 1);