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

ruby-changes:11998

From: matz <ko1@a...>
Date: Thu, 11 Jun 2009 13:34:54 +0900 (JST)
Subject: [ruby-changes:11998] Ruby:r23662 (ruby_1_8): * ext/bigdecimal/bigdecimal.c (VpToString): fixed a bug introduced

matz	2009-06-11 13:34:41 +0900 (Thu, 11 Jun 2009)

  New Revision: 23662

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

  Log:
    * ext/bigdecimal/bigdecimal.c (VpToString): fixed a bug introduced
      in r23613.  [ruby-talk:338957]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/ext/bigdecimal/bigdecimal.c

Index: ruby_1_8/ext/bigdecimal/bigdecimal.c
===================================================================
--- ruby_1_8/ext/bigdecimal/bigdecimal.c	(revision 23661)
+++ ruby_1_8/ext/bigdecimal/bigdecimal.c	(revision 23662)
@@ -3805,7 +3805,7 @@
 /* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
 {
     U_LONG i, ZeroSup;
-    U_LONG n, e;
+    U_LONG n, m, e, nn;
     char *pszSav = psz;
     S_LONG ex;
 
@@ -3821,12 +3821,18 @@
     *psz++ = '.';
     n = a->Prec;
     for(i=0;i < n;++i) {
+        m = BASE1;
         e = a->frac[i];
-	if((!ZeroSup) || e) {
-	    sprintf(psz, "%lu", e);    /* The reading zero(s) */
-	    psz += strlen(psz);
-	    /* as 0.00xx will be ignored. */
-	    ZeroSup = 0;    /* Set to print succeeding zeros */
+        while(m) {
+            nn = e / m;
+            if((!ZeroSup) || nn) {
+                sprintf(psz, "%lu", nn);    /* The reading zero(s) */
+                psz += strlen(psz);
+                /* as 0.00xx will be ignored. */
+                ZeroSup = 0;    /* Set to print succeeding zeros */
+            }
+            e = e - nn * m;
+            m /= 10;
         }
     }
     ex =(a->exponent) * BASE_FIG;
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 23661)
+++ ruby_1_8/ChangeLog	(revision 23662)
@@ -1,3 +1,8 @@
+Thu Jun 11 13:29:16 2009  Yukihiro Matsumoto  <matz@r...>
+
+	* ext/bigdecimal/bigdecimal.c (VpToString): fixed a bug introduced
+	  in r23613.  [ruby-talk:338957]
+
 Thu Jun  4 02:25:51 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* lib/base64.rb: typo fixed.  a patch from okkez.   [ruby-dev:38564]

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

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