[R] Best way to compute a sum

Bernardo Rangel Tura tura at centroin.com.br
Sat Jul 3 22:34:04 CEST 2010


On Fri, 2010-07-02 at 21:23 -0700, Roger Deangelis wrote:
> 
>   Although it does not apply to your series and is impractical,  it seems to
> me that the most accurate algorithm might be to add all the rational numbers
> whose sum and components can be represented  without error in binary first,
> ie 2.5 + .5 or 1/16 + 1/16 + 1/8.
> 
>   You could also get very clever and investigate a sum that should have an
> exact binary representation when the individual components do not, ie .1 +
> .2 + .2 = .5 and correct the sum.
> 
> Roger

Roger I think you must read: What Every Computer Scientist Should Know
About Floating-Point Arithmetic
( http://docs.sun.com/source/806-3568/ncg_goldberg.html )

I think your question and others like this question is answer in this
paper 
-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil



More information about the R-help mailing list