When I run:
import numpy as np
np.arange(14.1,15.1,0.1)
I get:
array([14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15. ])
yet when I run:
np.arange(15.1,16.1,0.1)
I get:
array([15.1, 15.2, 15.3, 15.4, 15.5, 15.6, 15.7, 15.8, 15.9, 16. , 16.1])
What is up with the missing 15.1
? Why does the output in one case show the final number and in the other case not?
I have read the documentation on numpy-arange. It states that the "interval does not include stop value, except in some cases where step is not an integer and floating point round-off affects the length of out."
My question is: How to get the code to behave consistent?
I am iterating over a list of paired numbers (e.g. 4 and 15, or 44.2 and 46.4) and for each pair, I want to create a list with steps of 0.1 between the pairs (e.g 4 and 4.5 would be: 4.1, 4.2, 4.3, 4.4, 4.5). But it is important that the code behaves consistent.