summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 15:24:47 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 15:24:47 +0000
commit25e5a75863a111d102f5efff1f9431d7b6c55867 (patch)
treefee42a6342eaed6856ddc775534b0350c00d09fc
parent2a38d9043e2eb16d7f3fcf3460dec5995a3195c6 (diff)
* bignum.c (calc_hbase): Make hbase the maximum power of base
representable in BDIGIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--bignum.c12
2 files changed, 11 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index aa86bec134..f9fa1e7af2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jun 1 00:19:50 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (calc_hbase): Make hbase the maximum power of base
+ representable in BDIGIT.
+
Fri May 31 23:56:13 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (calc_hbase): Extracted from rb_big2str0.
diff --git a/bignum.c b/bignum.c
index a19560a609..b8ff3fe76e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1125,12 +1125,12 @@ calc_hbase(int base, long *hbase_p, int *hbase_numdigits_p)
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;