Weird numpy.sum behavior when adding zeros
问题 I understand how mathematically-equivalent arithmentic operations can result in different results due to numerical errors (e.g. summing floats in different orders). However, it surprises me that adding zeros to sum can change the result. I thought that this always holds for floats, no matter what: x + 0. == x . Here's an example. I expected all the lines to be exactly zero. Can anybody please explain why this happens? M = 4 # number of random values Z = 4 # number of additional zeros for i in