aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 13:40:09 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 13:40:09 +0000
commit94e5fdf3366e4e79924c060dbb1218ed75518dde (patch)
tree770fd4132d9163f212ccf119c3dee179ffb1df04 /bignum.c
parentca10999c39a8cee3ff766a4ffed399abe6f22ae7 (diff)
downloadruby-94e5fdf3366e4e79924c060dbb1218ed75518dde.tar.gz
* bignum.c (rb_uint2big): Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/bignum.c b/bignum.c
index c39dcfda92..b0dc48c59b 100644
--- a/bignum.c
+++ b/bignum.c
@@ -336,21 +336,17 @@ rb_big_norm(VALUE x)
VALUE
rb_uint2big(VALUE n)
{
- long i = 0;
- BDIGIT *digits;
- VALUE big;
+ long i;
+ VALUE big = bignew(bdigit_roomof(SIZEOF_VALUE), 1);
+ BDIGIT *digits = BDIGITS(big);
#if SIZEOF_BDIGITS >= SIZEOF_VALUE
- big = bignew(1, 1);
- digits = BDIGITS(big);
digits[0] = n;
#else
- BDIGIT_DBL num = n;
- big = bignew(bdigit_roomof(SIZEOF_VALUE), 1);
- digits = BDIGITS(big);
- while (i < bdigit_roomof(SIZEOF_VALUE)) {
- digits[i++] = BIGLO(num);
- num = BIGDN(num);
+ i = 0;
+ for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) {
+ digits[i] = BIGLO(n);
+ n = BIGDN(n);
}
#endif