diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 16:32:40 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 16:32:40 +0000 |
| commit | fa98c208eda956d25b3a530c4b310fc653c267a4 (patch) | |
| tree | fd76495510b0ae5528eb523dc27a677b188b1ee9 | |
| parent | fb06765feb2840a7204059a0109a4f4d0de49947 (diff) | |
merges r20368 from trunk into ruby_1_9_1.
* ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return
Integer for #div operation.
* ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should raise
ZeroDivisionError if divisor is zero. [ruby-dev:37207]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | ext/bigdecimal/bigdecimal.c | 5 |
2 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,11 @@ +Thu Nov 27 10:40:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return + Integer for #div operation. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should raise + ZeroDivisionError if divisor is zero. [ruby-dev:37207] + Mon Nov 3 00:36:44 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp> * test/win32ole/test_win32ole_event.rb: rename test class. diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index b21041a329..93fab7b368 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1169,7 +1169,10 @@ BigDecimal_div2(int argc, VALUE *argv, VALUE self) Real *mod; obj = BigDecimal_DoDivmod(self,b,&div,&mod); if(obj!=(VALUE)0) return obj; - return ToValue(div); + if(VpIsNaN(div) && rb_equal(b, INT2FIX(0))) { + rb_raise(rb_eZeroDivError, "divided by 0"); + } + return BigDecimal_to_i(ToValue(div)); } else { /* div in BigDecimal sense */ U_LONG ix = (U_LONG)GetPositiveInt(n); if(ix==0) return BigDecimal_div(self,b); |
