Converting a number to a string
suggest changeInteger#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, the number is represented in base 10:
2.to_s # => "2"
10423.to_s # => "10423"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents