summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
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 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);