I have a list of float numbers, representing currency, and I need to turn them into integers, for precision.
The task is to turn float numbers into integers, likes:
- 0.95 => 95
- 1 => 100
- 1,465.01 => 146501
The problem is:
- I don't have access to change the input csv files
- The numbers came in a variety of ways (1.00, 1.0, 1, .95, 0.95, etc)
How can, safely, I turn these numbers into integers?
Some examples of my problem:
('16.81'.to_f * 100).to_i
=> 1680('16.81'.to_f * 100_00).to_i / 100
=> 1681('342.28'.to_f * 100).to_i
=> 34228('342.28'.to_f * 100_00).to_i / 100
=> 34227
__ EDIT __
By the way, I'm using ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin19]