ruby-changes:15679
From: yugui <ko1@a...>
Date: Mon, 3 May 2010 18:13:02 +0900 (JST)
Subject: [ruby-changes:15679] Ruby:r27597 (ruby_1_9_1): merges r26626 and r26627 from trunk into ruby_1_9_1. This fixes #3159.
yugui 2010-05-03 18:12:41 +0900 (Mon, 03 May 2010) New Revision: 27597 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27597 Log: merges r26626 and r26627 from trunk into ruby_1_9_1. This fixes #3159. -- * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision. [ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358] -- * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/ext/bigdecimal/bigdecimal.c branches/ruby_1_9_1/version.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 27596) +++ ruby_1_9_1/ChangeLog (revision 27597) @@ -1,3 +1,12 @@ +Tue Feb 9 23:48:25 2010 Yusuke Endoh <mame@t...> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too. + +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] + Thu Dec 10 01:12:55 2009 Nobuyoshi Nakada <nobu@r...> * parse.y (dyna_pop_gen): pop dvars. [ruby-dev:39861] Index: ruby_1_9_1/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_1_9_1/ext/bigdecimal/bigdecimal.c (revision 27596) +++ ruby_1_9_1/ext/bigdecimal/bigdecimal.c (revision 27597) @@ -951,7 +951,9 @@ if(!b) return DoSomeOne(self,r,'/'); SAVE(b); *div = b; - mx =(a->MaxPrec + b->MaxPrec + 1) * VpBaseFig(); + 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")); VpDivd(*c, *res, a, b); @@ -1023,8 +1025,8 @@ return (VALUE)0; } - 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")); @@ -1036,6 +1038,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; Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 27596) +++ ruby_1_9_1/version.h (revision 27597) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 422 +#define RUBY_PATCHLEVEL 423 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/