I need to work with decimals. In my program, the user need to put a number with decimals to convert that number.
The problem is: If I try to convert the argument into a number I get a integer without decimals.
# ARGV[0] is: 44.33
size = ARGV[0]
puts size.to_i
# size is: 44
# :(
You call to_i
, you get integer.
Try calling to_f
, you should get a float.
For more string conversion methods, look here.