Hi Andreas On Mon, Mar 24, 2008 at 7:28 PM, Andreas Klöckner <[EMAIL PROTECTED]> wrote: > I just got tripped up by this behavior in Numpy 1.0.4: > > >>> u = numpy.array([1,3]) > >>> v = numpy.array([0.2,0.1]) > >>> u+=v > >>> u > array([1, 3]) > >>> > > I think this is highly undesirable and should be fixed, or at least warned > about. Opinions?
I know the result is surprising, but it follows logically. You have created two integers in memory, and now you add 0.2 and 0.1 to both -- not enough to flip them over to the next value. The equivalent in C is roughly: #include <stdio.h> int main() { int i; int x[2] = {1,3}; x[0] += 0.2; x[1] += 0.1; printf("[%d %d]\n", x[0], x[1]); } Which results in the same answer. Regards Stéfan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion