When I generate an array using np.arange(start=0, stop= 29 * 4.42, step=4.42), the output turns out to be an array of size (30,) where it should be of size (29,). (While the numbers I use here seems to be hard-coded, they are necessarily in that way)
What I notice is that it only happens when I use a step size of 4.42 and make it stop at 29*4.42, which is 128.18. A slight tweak to either of these two number would make things right again, gernerating a array of size (29,) as it should be.
I am wondering if it is because 128.18 is so close to 128, which is 2^7, so it causes certain errors regarding to storage size of the variables? Any thought or insight would be appreciated. Thx!!
For reference, my numpy version is 1.21.5. And the problem is reproduced as in the following codes:
What I notice is that it only happens when I use a step size of 4.42 and make it stop at 29*4.42, which is 128.18. A slight tweak to either of these two number would make things right again, gernerating a array of size (29,) as it should be.
I am wondering if it is because 128.18 is so close to 128, which is 2^7, so it causes certain errors regarding to storage size of the variables? Any thought or insight would be appreciated. Thx!!
For reference, my numpy version is 1.21.5. And the problem is reproduced as in the following codes:
step = 4.42 a = np.arange(0, 29*step, step) print(a) print(a.shape)