[Numpy-discussion] Division by zero doesn't raise exception in the integer case.
Christopher Barker
Chris.Barker at noaa.gov
Wed Sep 20 17:17:58 CDT 2006
Travis Oliphant wrote:
>> In [77]: arange(5, dtype=int)/0
>> Out[77]: array([0, 0, 0, 0, 0])
> It is deliberate. Numarray introduced it (the only difference being
> that by default NumPy has division-by-zero erros turned off). It's tied
> to the way floating-point division-by zero is handled. There is a
> valid argument for having a separate integer-division flag so that you
> can raise exceptions for integer-division but not for floating-point
> division. I'm open to that change for 1.0rc1
+1 (+inf)
There is a BIG difference between getting an inf with a floating point
computation and getting a 0 with an integer one!
Also, the default integer-division flag should be set to raise an exception.
It sure would be nice to have special values for integers too....
Travis Oliphant wrote:
> Simulating and "integer-division-by-zero"
> hardware flag is not trivial as we would have to manage context
> switching ourselves. So, at least for 1.0, integer and floating-point
> division by zero are going to be handled the same.
Darn. Oh well.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (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