Re: [R] precision in seq

2008-02-05 Thread jim holtman
If you want 0,0.05,0.1,...0.95,1.00 then think about encoding as characters: > sprintf("%.2f", seq(0, 1, 0.05)) [1] "0.00" "0.05" "0.10" "0.15" "0.20" "0.25" "0.30" "0.35" "0.40" "0.45" "0.50" "0.55" [13] "0.60" "0.65" "0.70" "0.75" "0.80" "0.85" "0.90" "0.95" "1.00" > then you won't have the p

Re: [R] precision in seq

2008-02-05 Thread Duncan Murdoch
On 2/5/2008 7:21 AM, Eric Elguero wrote: > thank you to all who answered. > > >> 0+0.05+ > + 0.05+0.05+0.05+0.05+0.05+0.05+ > + 0.05+0.05+0.05+0.05+0.05+0.05+ > + 0.05+0.05+0.05+0.05+0.05+0.05 - 0.95 > [1] 3.330669e-16 > >> seq(0,1,0.05)[20] - 0.95 > [1] 1.110223e-16 > >> 0+19*0.05 - 0.95 > [1]

Re: [R] precision in seq

2008-02-05 Thread Eric Elguero
thank you to all who answered. > 0+0.05+ + 0.05+0.05+0.05+0.05+0.05+0.05+ + 0.05+0.05+0.05+0.05+0.05+0.05+ + 0.05+0.05+0.05+0.05+0.05+0.05 - 0.95 [1] 3.330669e-16 > seq(0,1,0.05)[20] - 0.95 [1] 1.110223e-16 > 0+19*0.05 - 0.95 [1] 1.110223e-16 so this is the way seq calculates. I would have gue

Re: [R] precision in seq

2008-02-05 Thread Peter Dalgaard
Barry Rowlingson wrote: > Prof Brian Ripley wrote: > >> FAQ Q7.31 and ?"==" should enlighten you. >> >> None of 0.05, 0.1 ... 0.9, 0.95 are exactly representable on a binary >> computer. >> > > Doesn't the string "0.95" constitute an exact representation? And my > computer is definitely

Re: [R] precision in seq

2008-02-05 Thread Barry Rowlingson
Prof Brian Ripley wrote: > FAQ Q7.31 and ?"==" should enlighten you. > > None of 0.05, 0.1 ... 0.9, 0.95 are exactly representable on a binary > computer. Doesn't the string "0.95" constitute an exact representation? And my computer is definitely binary. Although I suspect it is also bipolar.

Re: [R] precision in seq

2008-02-04 Thread Prof Brian Ripley
FAQ Q7.31 and ?"==" should enlighten you. None of 0.05, 0.1 ... 0.9, 0.95 are exactly representable on a binary computer. On Mon, 4 Feb 2008, Eric Elguero wrote: > Hi everybody, > > this is a warning more than a question. > > I noticed that seq produces approximate results: > >> seq(0,1,0.05)[1

Re: [R] precision in seq

2008-02-04 Thread jim holtman
FAQ 7.31 On 2/4/08, Eric Elguero <[EMAIL PROTECTED]> wrote: > Hi everybody, > > this is a warning more than a question. > > I noticed that seq produces approximate results: > > > seq(0,1,0.05)[19]==0.9 > [1] TRUE > > seq(0,1,0.05)[20]==0.95 > [1] FALSE > > seq(0,1,0.05)[21]==1 > [1] TRUE > > > seq

[R] precision in seq

2008-02-04 Thread Eric Elguero
Hi everybody, this is a warning more than a question. I noticed that seq produces approximate results: > seq(0,1,0.05)[19]==0.9 [1] TRUE > seq(0,1,0.05)[20]==0.95 [1] FALSE > seq(0,1,0.05)[21]==1 [1] TRUE > seq(0,1,0.05)[20]-0.95 [1] 1.110223024625157e-16 I do not understand why 0.9 and 1 are