[Deb-scipy-devel] Bug#441439: Bug#441439: Roundoff error results in arange vectors of wrong dimensions

Ed Schofield edschofield at gmail.com
Sat Sep 15 18:42:33 UTC 2007


On 9/9/07, Gudjon I. Gudjonsson <gudjon at gudjon.org> wrote:
> Subject: python-numpy: Roundoff error makes arange vectors of wrond dimensions
> Package: python-numpy
> Version: 1:1.0.3-1
> Severity: normal
>
> *** Please type your report below this line ***
> When I do the following in python:
> >>> from numpy import *
> >>> a=0.6
> >>> a
> 0.59999999999999998
> >>> arange(0,a,0.2)
> array([ 0. ,  0.2,  0.4])
> >>> a=0.4+0.2
> >>> a
> 0.60000000000000009
> >>> arange(0,a,0.2)
> array([ 0. ,  0.2,  0.4,  0.6])
>
> The array should include the following numbers
> 0, 0.2, 0.4 no matter if I define the end number as
> 0.2+0.4 or 0.6.

I've asked the upstream developers what they think of this. There's no
consensus yet, but the general view is that using floating point
values with arange() is a bad idea, but that this is not necessarily a
bug in NumPy. You can follow the thread here:

http://article.gmane.org/gmane.comp.python.numeric.general/16797

-- Ed





More information about the Deb-scipy-devel mailing list