Method: Integer#to_s
- Defined in:
- numeric.c
permalink #to_s(base = 10) ⇒ String Also known as: inspect
Returns a string containing the place-value representation of int
with radix base
(between 2 and 36).
12345.to_s #=> "12345"
12345.to_s(2) #=> "11000000111001"
12345.to_s(8) #=> "30071"
12345.to_s(10) #=> "12345"
12345.to_s(16) #=> "3039"
12345.to_s(36) #=> "9ix"
78546939656932.to_s(36) #=> "rubyrules"
3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 |
# File 'numeric.c', line 3536
static VALUE
int_to_s(int argc, VALUE *argv, VALUE x)
{
int base;
if (rb_check_arity(argc, 0, 1))
base = NUM2INT(argv[0]);
else
base = 10;
return rb_int2str(x, base);
}
|