How to fix this problem? np.arange(0,20.01,0.01)

The last element of "np.arange(0,20.01,0.01)" is 20.01 in my python result. Is this numpy error ?

On 3/4/23 18:11, siderique@gmail.com wrote:
This is due to inaccurate float value representation. The documentation for arange states: "When using a non-integer step, such as 0.1, it is often better to use |numpy.linspace| <https://numpy.org/devdocs/reference/generated/numpy.linspace.html#numpy.lins...>. See the Warning sections below for more information." Please read the warning section https://numpy.org/devdocs/reference/generated/numpy.arange.html#numpy-arange. Matti

On 3/4/23 18:11, siderique@gmail.com wrote:
This is due to inaccurate float value representation. The documentation for arange states: "When using a non-integer step, such as 0.1, it is often better to use |numpy.linspace| <https://numpy.org/devdocs/reference/generated/numpy.linspace.html#numpy.lins...>. See the Warning sections below for more information." Please read the warning section https://numpy.org/devdocs/reference/generated/numpy.arange.html#numpy-arange. Matti
participants (2)
-
Matti Picus
-
siderique@gmail.com