diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | bignum.c | 22 |
2 files changed, 16 insertions, 11 deletions
@@ -1,3 +1,8 @@ +Fri Jun 21 06:43:59 2013 Tanaka Akira <akr@fsij.org> + + * bignum.c (rb_ull2big): Refactored. + (rb_uint2big): Useless code removed. + Fri Jun 21 05:37:39 2013 Koichi Sasada <ko1@atdot.net> * gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when @@ -345,7 +345,6 @@ rb_uint2big(VALUE n) #if SIZEOF_BDIGITS >= SIZEOF_VALUE digits[0] = n; #else - i = 0; for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) { digits[i] = BIGLO(n); n = BIGDN(n); @@ -1830,19 +1829,20 @@ rb_str_to_inum(VALUE str, int base, int badcheck) static VALUE rb_ull2big(unsigned LONG_LONG n) { - BDIGIT_DBL num = n; - long i = 0; - BDIGIT *digits; - VALUE big; + long i; + VALUE big = bignew(DIGSPERLL, bdigit_roomof(SIZEOF_LONG_LONG)); + BDIGIT *digits = BDIGITS(big); - big = bignew(DIGSPERLL, 1); - digits = BDIGITS(big); - while (i < DIGSPERLL) { - digits[i++] = BIGLO(num); - num = BIGDN(num); +#if SIZEOF_BDIGITS >= SIZEOF_LONG_LONG + digits[0] = n; +#else + for (i = 0; i < bdigit_roomof(SIZEOF_LONG_LONG); i++) { + digits[i] = BIGLO(n); + n = BIGDN(n); } +#endif - i = DIGSPERLL; + i = bdigit_roomof(SIZEOF_LONG_LONG); while (i-- && !digits[i]) ; RBIGNUM_SET_LEN(big, i+1); return big; |