I want to get a list of numbers such as [-2.3,-2.2,...,0.2]
in Python
. However, the attempt:
[float(i)/10 for i in range(-23,2)]
will return [-2.2999999999999998, -2.2000000000000002, -2.1000000000000001, -2.0, -1.8999999999999999, -1.8, -1.7, -1.6000000000000001, -1.5, -1.3999999999999999, -1.3, -1.2, -1.1000000000000001, -1.0, -0.90000000000000002, -0.80000000000000004, -0.69999999999999996, -0.59999999999999998, -0.5, -0.40000000000000002, -0.29999999999999999, -0.20000000000000001, -0.10000000000000001, 0.0]
How do I fix this?
Round doesn't work:
>>> round(float(-23)/float(10),3)
-2.2999999999999998
It's for an eventual write to CSV or pass to another language through main method.