aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
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