aboutsummaryrefslogtreecommitdiffstats
path: root/ext/bigdecimal
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index e0cd4b006b..49e5afee9c 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -797,7 +797,8 @@ BigDecimal_coerce(VALUE self, VALUE other)
Real *b;
if (RB_TYPE_P(other, T_FLOAT)) {
- obj = rb_assoc_new(other, BigDecimal_to_f(self));
+ GUARD_OBJ(b, GetVpValueWithPrec(other, DBL_DIG+1, 1));
+ obj = rb_assoc_new(ToValue(b), self);
}
else {
if (RB_TYPE_P(other, T_RATIONAL)) {