* bignum.c (calc_hbase): Extracted from rb_big2str0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fc1f9d2cb2
commit
2a38d9043e
@ -1,3 +1,7 @@
|
|||||||
|
Fri May 31 23:56:13 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (calc_hbase): Extracted from rb_big2str0.
|
||||||
|
|
||||||
Fri May 31 23:22:24 2013 Tanaka Akira <akr@fsij.org>
|
Fri May 31 23:22:24 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).
|
* bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).
|
||||||
|
24
bignum.c
24
bignum.c
@ -1119,6 +1119,23 @@ big2str_karatsuba(VALUE x, int base, char* ptr,
|
|||||||
return lh + ll;
|
return lh + ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
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_p = hbase;
|
||||||
|
*hbase_numdigits_p = hbase_numdigits;
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_big2str0(VALUE x, int base, int trim)
|
rb_big2str0(VALUE x, int base, int trim)
|
||||||
{
|
{
|
||||||
@ -1144,12 +1161,7 @@ rb_big2str0(VALUE x, int base, int trim)
|
|||||||
ptr = RSTRING_PTR(ss);
|
ptr = RSTRING_PTR(ss);
|
||||||
ptr[0] = RBIGNUM_SIGN(x) ? '+' : '-';
|
ptr[0] = RBIGNUM_SIGN(x) ? '+' : '-';
|
||||||
|
|
||||||
hbase = base*base;
|
calc_hbase(base, &hbase, &hbase_numdigits);
|
||||||
hbase_numdigits = 2;
|
|
||||||
#if SIZEOF_BDIGITS > 2
|
|
||||||
hbase *= hbase;
|
|
||||||
hbase_numdigits *= 2;
|
|
||||||
#endif
|
|
||||||
off = !(trim && RBIGNUM_SIGN(x)); /* erase plus sign if trim */
|
off = !(trim && RBIGNUM_SIGN(x)); /* erase plus sign if trim */
|
||||||
xx = rb_big_clone(x);
|
xx = rb_big_clone(x);
|
||||||
RBIGNUM_SET_SIGN(xx, 1);
|
RBIGNUM_SET_SIGN(xx, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user