1.#QNAN Solution

Grant Edwards grante at visi.com
Tue May 8 13:52:36 EDT 2007


On 2007-05-08, Greg Corradini <gregcorradini at gmail.com> wrote:

> I'm running descriptive stats on mileages from a database
> (float numbers, about a million records). My sum returns
> 1.#QNAN, which I understand from searching this forum is an
> error.

Not necessarily.  You've ended up with a floating point "not a
number" value (AKA a NaN).  That might or might not be an
error.  Whether it's an error not not depends on your input
data and your algorithm.

> While I'm looking for help in solving this problem, I'm more
> interested in a general explanation about the cause of this
> problem.

If you're asking how you end up with a NaN, there are several
ways to generate a NaN:

  0/0
  
  Inf*0
  
  Inf/Inf
  
  Inf-Inf
  
  Almost any operation on a NaN 

http://en.wikipedia.org/wiki/NaN
http://steve.hollasch.net/cgindex/coding/ieeefloat.html

-- 
Grant Edwards                   grante             Yow! Spreading peanut
                                  at               butter reminds me of
                               visi.com            opera!!  I wonder why?



More information about the Python-list mailing list