This is probably Apple Silicon specific, not OSX per se:> sum(rep(1 / 9, 9)) - 1[1] 0> On 23 Oct 2024, at 07:26 , Stevie Pederson <stephen.pederson.au at gmail.com> wrote: > > sum(rep(1 / 9, 9)) - 1 > # [1] 2.220446e-16-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
>>>>> "pd" == peter dalgaard >>>>> on Thu, 24 Oct 2024 11:00:25 +0200 writes:pd> This is probably Apple Silicon specific, not OSX per se: >> sum(rep(1 / 9, 9)) - 1 pd> [1] 0 >> On 23 Oct 2024, at 07:26 , Stevie Pederson >> <stephen.pederson.au at gmail.com> wrote: >> >> sum(rep(1 / 9, 9)) - 1 # [1] 2.220446e-16 But indeed, it *is* a bug *always* to assume that double precision arithmetic is exact be it in R or not (unless you *know* that all the numbers involved are of the form <integer> * 2^k ; k in "around" (-1000):1000 ) Martin Maechler