diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-08 11:20:51 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-08 11:20:51 +0000 |
commit | 0727a22c69641c98edd50668322d8f0270bec457 (patch) | |
tree | 3be4ccaa17b4a7a14baa19896aa648be49247514 /ext/bigdecimal/bigdecimal.c | |
parent | e54e3d70a8f70ec0f6426e29dcde9bff884dc8d0 (diff) | |
download | ruby-0727a22c69641c98edd50668322d8f0270bec457.tar.gz |
* 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
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 3 |
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)) { |