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

Konrad Hinsen hinsen at cnrs-orleans.fr
Wed Jun 7 12:36:06 EDT 2000


Charles G Waldman <cgw at fnal.gov> writes:

> Konrad Hinsen <hinsen at cnrs-orleans.fr> writes:
> 
> > I'd prefer a portable solution to one that reflects the system math
> > library. I had the same problem under AIX, and I solved it by patching
> > Python. I just wonder if someone has the patience to work out a
> > patch that would create the same behaviour independently of what the
> > math library does. Not me, unfortunately...
> 
> 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.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------



More information about the Python-list mailing list