On Feb 21, 2:05 am, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-02-20, joanne matthews (RRes-Roth) <[EMAIL PROTECTED]> wrote:
>
> > I'm getting different results when I add up a list of floats depending
> > on the order that I list the floats.

>
> Don't use floating point if you expect exact results.

It's not the floating point that's the problem, it's the radix, in
this case 2, not being able to express n/10 exactly. As the tutorial
points out, radix-10 has problems representing n/3 (and n/7 and ...)
exactly.

Another take: Don't expect exact results. If the input is exact to 1
or two decimal places, don't expect the sum to be exact to 15 or more
decimal places.

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

Reply via email to