Reputation: 67
import numpy as np
print(np.arange(-2, 2, 0.5, int))
so we have -2 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5
output: [-2 -1 0 1 2 3 4 5]
can someone explain the output?
Upvotes: 1
Views: 165
Reputation: 169
Basically, what you have is rounding of float (-1.5) to an integer(-1). Then arrange() continues addition to a new integer(-1+0.5), which results in float(0.5) again. The floats are not allowed, so it's rounded to 0. And so the cycle continues producing observed output.
Upvotes: 4