Handling division by zero
Stephen Boulet
stephen.boulet at motorola.com
Mon Dec 3 19:15:43 EST 2001
I have some math operations going on where sometimes the divisor will be
zero.
Is this an acceptable way to handle this:
1. test if the divisor is zero
2. if so, instead of dividing by it, multiply by a large number
?
How do I figure out what a large number on my python 2.1 for NT
distribution is? Right now, I'm using:
MAXPOS = 0x7fffffff
MAXNEG = 0x80000000
I've imported scipy (which includes Numeric), and the numbers are
complex, if that matters, although:
>>> from scipy import *
>>> 0 == 0j
1
Thanks.
-- Stephen
More information about the Python-list
mailing list