mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
* bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79be10475f
commit
69263bb755
2 changed files with 9 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Aug 1 23:33:01 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
|
||||||
|
|
||||||
Thu Aug 1 21:02:48 2013 Tanaka Akira <akr@fsij.org>
|
Thu Aug 1 21:02:48 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (rb_big2str1): Raise an error for too big number.
|
* bignum.c (rb_big2str1): Raise an error for too big number.
|
||||||
|
|
9
bignum.c
9
bignum.c
|
@ -141,6 +141,7 @@ static inline VALUE bigtrunc(VALUE x);
|
||||||
|
|
||||||
static VALUE bigsq(VALUE x);
|
static VALUE bigsq(VALUE x);
|
||||||
static void bigdivmod(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp);
|
static void bigdivmod(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp);
|
||||||
|
static VALUE power_cache_get_power(int base, int power_level, size_t *numdigits_ret);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nlz16(uint16_t x)
|
nlz16(uint16_t x)
|
||||||
|
@ -3833,13 +3834,12 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
||||||
BDIGIT_DBL dd;
|
BDIGIT_DBL dd;
|
||||||
BDIGIT_DBL current_base;
|
BDIGIT_DBL current_base;
|
||||||
int m;
|
int m;
|
||||||
|
int power_level = 0;
|
||||||
|
|
||||||
uds = ALLOCV_N(BDIGIT, tmpuv, 2*num_bdigits);
|
uds = ALLOCV_N(BDIGIT, tmpuv, 2*num_bdigits);
|
||||||
vds = uds + num_bdigits;
|
vds = uds + num_bdigits;
|
||||||
|
|
||||||
powerv = bignew(2, 1);
|
powerv = power_cache_get_power(base, power_level, NULL);
|
||||||
BDIGITS(powerv)[0] = BIGLO(power);
|
|
||||||
BDIGITS(powerv)[1] = (BDIGIT)BIGDN(power);
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
dd = 0;
|
dd = 0;
|
||||||
|
@ -3879,7 +3879,8 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
||||||
MEMCPY(vds+i, uds+i, BDIGIT, num_bdigits-i);
|
MEMCPY(vds+i, uds+i, BDIGIT, num_bdigits-i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
powerv = bigtrunc(bigsq(powerv));
|
power_level++;
|
||||||
|
powerv = power_cache_get_power(base, power_level, NULL);
|
||||||
tds = vds;
|
tds = vds;
|
||||||
vds = uds;
|
vds = uds;
|
||||||
uds = tds;
|
uds = tds;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue