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

ruby-changes:28954

From: akr <ko1@a...>
Date: Sat, 1 Jun 2013 00:25:01 +0900 (JST)
Subject: [ruby-changes:28954] akr:r41006 (trunk): * bignum.c (calc_hbase): Make hbase the maximum power of base

akr	2013-06-01 00:24:47 +0900 (Sat, 01 Jun 2013)

  New Revision: 41006

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

  Log:
    * bignum.c (calc_hbase): Make hbase the maximum power of base
      representable in BDIGIT.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41005)
+++ ChangeLog	(revision 41006)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jun  1 00:19:50 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (calc_hbase): Make hbase the maximum power of base
+	  representable in BDIGIT.
+
 Fri May 31 23:56:13 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (calc_hbase): Extracted from rb_big2str0.
Index: bignum.c
===================================================================
--- bignum.c	(revision 41005)
+++ bignum.c	(revision 41006)
@@ -1125,12 +1125,12 @@ calc_hbase(int base, long *hbase_p, int https://github.com/ruby/ruby/blob/trunk/bignum.c#L1125
     long hbase;
     int hbase_numdigits;
 
-    hbase = base*base;
-    hbase_numdigits = 2;
-#if SIZEOF_BDIGITS > 2
-    hbase *= hbase;
-    hbase_numdigits *= 2;
-#endif
+    hbase = base;
+    hbase_numdigits = 1;
+    while (hbase <= (~(BDIGIT)0) / base) {
+        hbase *= base;
+        hbase_numdigits++;
+    }
 
     *hbase_p = hbase;
     *hbase_numdigits_p = hbase_numdigits;

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

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