[前][次][番号順一覧][スレッド一覧]

ruby-changes:14766

From: mame <ko1@a...>
Date: Tue, 9 Feb 2010 23:59:19 +0900 (JST)
Subject: [ruby-changes:14766] Ruby:r26627 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.

mame	2010-02-09 23:49:41 +0900 (Tue, 09 Feb 2010)

  New Revision: 26627

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26627

  Log:
    * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.

  Modified files:
    trunk/ChangeLog
    trunk/ext/bigdecimal/bigdecimal.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26626)
+++ ChangeLog	(revision 26627)
@@ -1,3 +1,7 @@
+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.
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 26626)
+++ ext/bigdecimal/bigdecimal.c	(revision 26627)
@@ -882,7 +882,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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]