0

I found a very strange behaviour of numpy.arange.

If I wrote

np.arange(1.1, 1.7, 0.1)

it returns array([ 1.1, 1.2, 1.3, 1.4, 1.5, 1.6]) as expected.

However, when I wrote:

np.arange(1.1, 1 + 0.1 * 7, 0.1)

it returns array([ 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7]).

Is this a bug or I used it in a wrong way?

spacegoing
  • 5,056
  • 5
  • 25
  • 42

0 Answers0