Re: Weird result returned from adding floats depending on order I add them
- From: "John Machin" <sjmachin@xxxxxxxxxxx>
- Date: 20 Feb 2007 07:22:24 -0800
On Feb 21, 2:05 am, Grant Edwards <gra...@xxxxxxxx> wrote:
On 2007-02-20, joanne matthews (RRes-Roth) <joanne.matth...@xxxxxxxxxxx> 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.
.
- Follow-Ups:
- Re: Weird result returned from adding floats depending on order I add them
- From: Grant Edwards
- Re: Weird result returned from adding floats depending on order I add them
- References:
- Weird result returned from adding floats depending on order I add them
- From: joanne matthews (RRes-Roth)
- Re: Weird result returned from adding floats depending on order I add them
- From: Grant Edwards
- Weird result returned from adding floats depending on order I add them
- Prev by Date: Re: Sorting directory contents
- Next by Date: Re: Sorting directory contents
- Previous by thread: Re: Weird result returned from adding floats depending on order I add them
- Next by thread: Re: Weird result returned from adding floats depending on order I add them
- Index(es):
Relevant Pages
|