Re: [R] question about precision, floor, and powers of two.

2005-11-08 Thread Patrick Connolly
On Fri, 04-Nov-2005 at 04:58PM +0100, Peter Dalgaard wrote: |> In this particular case, it is slightly odd that we can't get an exact |> answer for operations that could in principle be carried out using |> integer arithmetic, but we're actually calculating log(8)/log(2). |> |> (Curiously, the s

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Prof Brian Ripley
On Fri, 4 Nov 2005, Thomas Lumley wrote: > On Fri, 4 Nov 2005, Uwe Ligges wrote: > >> Dr Carbon wrote: >> >>> At the risk of being beaten about the face and body, can somebody explain >>> why the middle example: log2(2^3); floor(log2(2^3)) is different than >>> examples 1 and 3? >> >> >> Because >

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Thomas Lumley
On Fri, 4 Nov 2005, Uwe Ligges wrote: > Dr Carbon wrote: > >> At the risk of being beaten about the face and body, can somebody explain >> why the middle example: log2(2^3); floor(log2(2^3)) is different than >> examples 1 and 3? > > > Because > > > log2(2^3) - 3 > [1] -4.440892e-16 > This is a

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Duncan Murdoch
On 11/4/2005 10:58 AM, Peter Dalgaard wrote: > Uwe Ligges <[EMAIL PROTECTED]> writes: > >> Dr Carbon wrote: >> >> > At the risk of being beaten about the face and body, can somebody explain >> > why the middle example: log2(2^3); floor(log2(2^3)) is different than >> > examples 1 and 3? >> >> >

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Berton Gunter
> In this particular case, it is slightly odd that we can't get an exact > answer for operations that could in principle be carried out using > integer arithmetic, but we're actually calculating log(8)/log(2). > > (Curiously, the same effect is not seen on Linux or Solaris until > > > log2(2^2

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Prof Brian Ripley
On Fri, 4 Nov 2005, Peter Dalgaard wrote: > Uwe Ligges <[EMAIL PROTECTED]> writes: > >> Dr Carbon wrote: >> >>> At the risk of being beaten about the face and body, can somebody explain >>> why the middle example: log2(2^3); floor(log2(2^3)) is different than >>> examples 1 and 3? >> >> >> Because

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Peter Dalgaard
Uwe Ligges <[EMAIL PROTECTED]> writes: > Dr Carbon wrote: > > > At the risk of being beaten about the face and body, can somebody explain > > why the middle example: log2(2^3); floor(log2(2^3)) is different than > > examples 1 and 3? > > > Because > > > log2(2^3) - 3 > [1] -4.440892e-16 > >

Re: [R] question about precision, floor, and powers of two.

2005-11-04 Thread Uwe Ligges
Dr Carbon wrote: > At the risk of being beaten about the face and body, can somebody explain > why the middle example: log2(2^3); floor(log2(2^3)) is different than > examples 1 and 3? Because > log2(2^3) - 3 [1] -4.440892e-16 see the R FAQ "Why doesn't R think these numbers are equal?". Uwe

[R] question about precision, floor, and powers of two.

2005-11-04 Thread Dr Carbon
At the risk of being beaten about the face and body, can somebody explain why the middle example: log2(2^3); floor(log2(2^3)) is different than examples 1 and 3? > log2(2^2); floor(log2(2^2)) [1] 2 [1] 2 > log2(2^3); floor(log2(2^3)) [1] 3 [1] 2 > log2(2^4); floor(log2(2^4)) [1] 4 [1] 4 > DrC