Convert string to float : Convert to Float « Number « Ruby






Convert string to float


'3.14'.to_f                     # => 3.14
'1.602e-19'.to_f                # => 1.602e-19

 








Related examples in the same category

1.create or convert floating-point numbers with Kernel's Float method
2.the percentage
3.try weird conversions