When I convert string to float, how do I put a dot two houses before the end? This is a example of what I want to do.
"000001909".to_f = 19.09
But I only get this:
"000001909".to_f = 1909.0
When I convert string to float, how do I put a dot two houses before the end? This is a example of what I want to do.
"000001909".to_f = 19.09
But I only get this:
"000001909".to_f = 1909.0
That string represents the value 1909
so merely to_f
ing it won't work. You need to divide by 100.0 to move the decimal point over two "houses" as you so eloquently put it:
"000001909".to_f / 100.0 # => 19.09
Having a string with a dot in it will output the expected result as well:
"0000019.09".to_f # => 19.09