ruby-changes:8833
From: matz <ko1@a...>
Date: Thu, 27 Nov 2008 10:43:38 +0900 (JST)
Subject: [ruby-changes:8833] Ruby:r20368 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return
matz 2008-11-27 10:43:14 +0900 (Thu, 27 Nov 2008) New Revision: 20368 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20368 Log: * 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] Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c Index: ChangeLog =================================================================== --- ChangeLog (revision 20367) +++ ChangeLog (revision 20368) @@ -1,3 +1,11 @@ +Thu Nov 27 10:40:52 2008 Yukihiro Matsumoto <matz@r...> + + * 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] + Wed Nov 26 23:15:47 2008 Yukihiro Matsumoto <matz@r...> * strftime.c (STRFTIME): use rb_strftime() recursively, instead of Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 20367) +++ ext/bigdecimal/bigdecimal.c (revision 20368) @@ -1169,7 +1169,10 @@ 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/