[Numpy-discussion] Testing for close to zero?
Jonathan Taylor
jonathan.taylor at utoronto.ca
Mon Jan 19 15:43:55 EST 2009
Hi,
When solving a quadratic equation I get that alpha =
-3.78336776728e-31 which I believe to be far below machine precision:
finfo(float).eps
2.2204460492503131e-16
But an if statement like:
if alpha == 0:
...
does not catch this. Is there a better way to check for things that
are essentially zero or should I really be using
if np.abs(alpha) < finfo(float).eps:
...
?
Thanks for any help.
Jonathan.
More information about the NumPy-Discussion
mailing list