aboutsummaryrefslogtreecommitdiffstats
path: root/ext/bigdecimal
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 /ext/bigdecimal
parente337c7f9793ae9fc883d7a86f5954c3ba83566dc (diff)
downloadruby-1db209763a70b825db775e684ef3a21a6b5b9757.tar.gz
* 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
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 06b3886eb5..2a0aea8b32 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);