Skip to content

Commit

Permalink
* ext/bigdecimal/bigdecimal.c (BigDecimal_coerce): support
Browse files Browse the repository at this point in the history
   coercing into Rational.   [ruby-core:23415]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed May 10, 2009
1 parent 81cf906 commit 70abf7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon May 11 08:37:04 2009 Yukihiro Matsumoto <[email protected]>

* ext/bigdecimal/bigdecimal.c (BigDecimal_coerce): support
coercing into Rational. [ruby-core:23415]

Mon May 11 04:39:45 2009 Yukihiro Matsumoto <[email protected]>

* lib/net/smtp.rb (Net::SMTP#check_auth_args): should not change
Expand Down
15 changes: 10 additions & 5 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,16 @@ BigDecimal_coerce(VALUE self, VALUE other)
ENTER(2);
VALUE obj;
Real *b;
if(TYPE(other) == T_FLOAT) {
obj = rb_assoc_new(other, BigDecimal_to_f(self));
} else {
GUARD_OBJ(b,GetVpValue(other,1));
obj = rb_assoc_new(b->obj, self);
switch (TYPE(other)) {
case T_FLOAT:
obj = rb_assoc_new(other, BigDecimal_to_f(self));
break;
case T_RATIONAL:
obj = rb_assoc_new(other, BigDecimal_to_r(self));
break;
default:
GUARD_OBJ(b,GetVpValue(other,1));
obj = rb_assoc_new(b->obj, self);
}
return obj;
}
Expand Down

0 comments on commit 70abf7e

Please sign in to comment.