summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index f0a0e3c279..4db0834ae3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -862,6 +862,8 @@ rb_int_zero_p(VALUE num)
* Of the Core and Standard Library classes,
* Integer, Float, Rational, and Complex use this implementation.
*
+ * Related: #zero?
+ *
*/
static VALUE
@@ -5453,11 +5455,12 @@ rb_fix_digits(VALUE fix, long base)
return rb_ary_new_from_args(1, INT2FIX(0));
digits = rb_ary_new();
- while (x > 0) {
+ while (x >= base) {
long q = x % base;
rb_ary_push(digits, LONG2NUM(q));
x /= base;
}
+ rb_ary_push(digits, LONG2NUM(x));
return digits;
}