ruby-changes:14765
From: mame <ko1@a...>
Date: Tue, 9 Feb 2010 23:30:51 +0900 (JST)
Subject: [ruby-changes:14765] Ruby:r26626 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision.
mame 2010-02-09 23:30:30 +0900 (Tue, 09 Feb 2010) New Revision: 26626 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26626 Log: * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision. [ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358] Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c Index: ChangeLog =================================================================== --- ChangeLog (revision 26625) +++ ChangeLog (revision 26626) @@ -1,3 +1,8 @@ +Tue Feb 9 23:26:07 2010 Yusuke Endoh <mame@t...> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision. + [ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358] + Tue Feb 9 22:23:27 2010 Yusuke Endoh <mame@t...> * io.c (READ_CHECK): do not select fd before reading, that had made Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 26625) +++ ext/bigdecimal/bigdecimal.c (revision 26626) @@ -970,8 +970,8 @@ return Qtrue; } - mx = a->Prec; - if(mx<b->Prec) mx = b->Prec; + mx = a->Prec+abs(a->exponent); + if(mx<b->Prec+abs(b->exponent)) mx = b->Prec+abs(b->exponent); mx =(mx + 1) * VpBaseFig(); GUARD_OBJ(c,VpCreateRbObject(mx, "0")); GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0")); @@ -983,6 +983,7 @@ VpAddSub(c,a,res,-1); if(!VpIsZero(c) && (VpGetSign(a)*VpGetSign(b)<0)) { VpAddSub(res,d,VpOne(),-1); + GUARD_OBJ(d,VpCreateRbObject(GetAddSubPrec(c, b)*(VpBaseFig() + 1), "0")); VpAddSub(d ,c,b, 1); *div = res; *mod = d; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/