Converting a number to a string

suggest change

Fixnum#to_s takes an optional base argument and represents the given number in that base:

2.to_s(2)   # => "10"
3.to_s(2)   # => "11"
3.to_s(3)   # => "10"
10.to_s(16) # => "a"

If no argument is provided, then it represents the number in base 10

2.to_s # => "2"
10423.to_s # => "10423"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents