diff options
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } |