mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@27597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4fcb855ff3
commit
b1809bcff1
3 changed files with 16 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
Tue Feb 9 23:48:25 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.
|
||||
|
||||
Tue Feb 9 23:26:07 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* parse.y (dyna_pop_gen): pop dvars. [ruby-dev:39861]
|
||||
|
|
|
@ -951,7 +951,9 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
|
|||
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 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
|
|||
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 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
|
|||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue