Convert integer to string by parameter : Convert to String « Number « Ruby






Convert integer to string by parameter


42.to_s(10)                       # => "42"
-100.to_s(2)                      # => "-1100100"
255.to_s(16)                      # => "ff"
1442151747.to_s(36)               # => "number"

 








Related examples in the same category

1.Integer passed into a string with interpolation
2.Substituting Variables Into Strings
3.constant value interpolation
4.String interpolation with method call
5.String interpolation with calculation
6.Convert float to string
7.Convert string to integer with error