C only does modular arithmetic for unsigned types. Signed types (like i2 used here, is should be signed short) are not allowed to overflow in C. I.e. not only is the result not guaranteed to be modular, or not guaranteed to be consistent, the behavior of the whole program is not specified if it allows signed integer overflow. In practice, your often get two's complement arithmetic, because this is what all current CPUs implement.
So, does numpy implement modular (two's complement) arithmetic for signed types, or does it leave it to C compiler, which does not provide any guarantees? Eugene From: numpy-discussion-boun...@scipy.org [mailto:numpy-discussion-boun...@scipy.org] On Behalf Of Charles R Harris Sent: Tuesday, May 14, 2013 2:25 PM To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] Integer overflow in test_einsum (1.7.1) I don't know if it was intended in the test, but numpy doesn't guard against integer overflow. Rather, it takes the C approach and does modular arithmetic. I don't know how to fix that or even if it could be at this point given the historical lack of support. I suppose at some point there could be user type that made such checks, but it would be slower. Chuck This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion