1.#QNAN Solution

Alex Martelli aleax at mac.com
Tue May 8 23:17:33 EDT 2007


Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:

> En Tue, 08 May 2007 14:14:58 -0300, Greg Corradini  
> <gregcorradini at gmail.com> escribió:
> 
> > 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.
> >
> > While I'm looking for help in solving this problem, I'm more interested
> > in a
> > general explanation about the cause of this problem. Any ideas?
> 
> If you are summing a million floating point numbers, using a naive  
> algorithm may give you wrong results.
> Look for "Kahan summation algorithm" (even discussed some weeks ago in
> this group).

Or, just check <http://en.wikipedia.org/wiki/Kahan_summation_algorithm>
etc.  I can't think offhand of a case where using the wrong/naive
algorithm would give a NAN while Kahan's would converge, tho.


Alex



More information about the Python-list mailing list