From 0727a22c69641c98edd50668322d8f0270bec457 Mon Sep 17 00:00:00 2001 From: mrkn Date: Sun, 8 Dec 2013 11:20:51 +0000 Subject: * bigdecimal.c (BigDecimal_coerce): convert a Float to a BigDecimal instead of converting the receiver to a Float. [ruby-core:58756] [Bug #9192] * test/bigdecimal/test_bigdecimal.rb: add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/bigdecimal/bigdecimal.c') 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)) { -- cgit v1.2.3