math.exp underflow (was: exp behaviour: is it a bug ?)

Johann Hibschman johann at physics.berkeley.edu
Wed Jun 7 13:09:06 EDT 2000


Konrad Hinsen writes:

> Charles G Waldman <cgw at fnal.gov> writes:
>> 
>> What do you think the consistent behavior should be?  Should
>> math.exp(-10000) return 0, or raise some exception?

> I have yet to encounter a case where returning 0 would cause a problem,
> so I'd vote for that solution. But raising an execption systematically
> would be fine as well, one could then catch it and return 0 if that's
> what is wanted.

Unsignalled underflows are very bad.  Most of my work conceptually
fits on a log-log scale, so the difference between 0 and 10^-100 is
immense.  If something underflows, I want to know that at the point of
underflow, not at the point where I try to take the log of it.


-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list