[Numpy-discussion] Binary ufuncs: minimum

Christopher Barker Chris.Barker at noaa.gov
Tue May 27 18:07:28 EDT 2008


Charles R Harris wrote:

> Yep, abs fails:
> 
> In [1]: abs(array([-128,-128], dtype=int8))
> Out[1]: array([-128, -128], dtype=int8)

Well, yes, but this is a know vagary of the the hardware implementation 
for signed integers, as demonstrated by that JAVA Puzzles video that Jon 
Wright pointed us to a couple days ago. (Which to me could have been 
titled: "Why I don't want to use JAVA")

Sure, it could be fixed in this case by promoting to a larger type, but 
it's going to fail at the largest integer anyway, and I don't think any 
expects abs() to return a new type.

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list