Russell E. Owen wrote:
> In article <[EMAIL PROTECTED]>,
>  Christian Heimes <[EMAIL PROTECTED]> wrote:
> 
>> Grant Edwards wrote:
>>> In many applications (e.g. process control) propogating NaN
>>> values are way too useful to avoid.  Avoiding NaN would make a
>>> lot of code far more complicated than would using them.
>> NaNs are very useful for experienced power users but they are very
>> confusing for newbies or developers without a numerical background.
>>
>> It's very easy to create an inf or nan in Python:
>>
>> inf = 1E+5000
>> ninf = -inf
>> nan = inf * 0.
>>
>> 1E5000 creates a nan because it is *much* bigger than DBL_MAX (around
>> 1E+308). In fact it is even larger than LDBL_MAX (around 1E+4932).
> 
> Isn't it safer to use float("inf"), float("-inf") and float("nan") to 
> create the necessary items?

In currently-released versions of Python, these are not portable. 
float(some_string) just passes the string to the platform's conversion 
function. 
There is no standard defining what to do with "nan" or "inf". On Linux, these 
work as intended, but on Windows, they are errors.

Christian is working on a branch to standardize these forms for Python 2.6. See 
"math and numerical fixes" in this thread.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to