123.5.to_s #=> "123.5"
String(123.5) #=> "123.5"
Usually, String()
will just call #to_s
.
Methods Kernel#sprintf
and String#%
behave similar to C:
sprintf("%s", 123.5) #=> "123.5"
"%s" % 123.5 #=> "123.5"
"%d" % 123.5 #=> "123"
"%.2f" % 123.5 #=> "123.50"