On 9/14/07, Ed Schofield <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > This was reported yesterday as a bug in Debian's numpy package: > > >>> len(numpy.arange(0, 0.6, 0.1)) == len(numpy.arange(0, 0.4+0.2, 0.1)) > False > > The cause is this: > > >>> ceil((0.4+0.2)/0.1) > 7.0 > > >>> ceil(0.6/0.1) > 6.0 > > which holds for both numpy's and the standard library's ceil().
Since none of the numbers are exactly represented in IEEE floating point, this sort of oddity is expected. If you look at the exact values, (.4 + .2)/.1 > 6 and .6/.1 < 6 . That said, I would expect something like ceil(interval/delta - relatively_really_small_number) would generally return the expected result. Matlab probably plays these sort of games. The downside is encouraging bad programming habits. In this case, the programmer should be using linspace.. Chuck.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion