[R] question about precision, floor, and powers of two.
Patrick Connolly
p.connolly at hortresearch.co.nz
Tue Nov 8 20:54:08 CET 2005
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 same effect is not seen on Linux or Solaris until
|>
|> > log2(2^29)-29
|> [1] 3.552714e-15
"Until" is not quite the word:
> x <- 2:100
> data.frame(x, D = log2(2^x) -x)
x D
1 2 0.000000e+00
2 3 0.000000e+00
3 4 0.000000e+00
4 5 0.000000e+00
5 6 0.000000e+00
6 7 0.000000e+00
7 8 0.000000e+00
8 9 0.000000e+00
9 10 0.000000e+00
10 11 0.000000e+00
11 12 0.000000e+00
12 13 0.000000e+00
13 14 0.000000e+00
14 15 0.000000e+00
15 16 0.000000e+00
16 17 0.000000e+00
17 18 0.000000e+00
18 19 0.000000e+00
19 20 0.000000e+00
20 21 0.000000e+00
21 22 0.000000e+00
22 23 0.000000e+00
23 24 0.000000e+00
24 25 0.000000e+00
25 26 0.000000e+00
26 27 0.000000e+00
27 28 0.000000e+00
28 29 3.552714e-15
29 30 0.000000e+00
30 31 3.552714e-15
31 32 0.000000e+00
32 33 0.000000e+00
33 34 0.000000e+00
34 35 0.000000e+00
35 36 0.000000e+00
36 37 0.000000e+00
37 38 0.000000e+00
38 39 7.105427e-15
39 40 0.000000e+00
40 41 0.000000e+00
41 42 0.000000e+00
42 43 0.000000e+00
43 44 0.000000e+00
44 45 0.000000e+00
45 46 0.000000e+00
46 47 7.105427e-15
47 48 0.000000e+00
48 49 0.000000e+00
49 50 0.000000e+00
50 51 7.105427e-15
51 52 0.000000e+00
52 53 0.000000e+00
53 54 0.000000e+00
54 55 7.105427e-15
55 56 0.000000e+00
56 57 0.000000e+00
57 58 7.105427e-15
58 59 7.105427e-15
59 60 0.000000e+00
60 61 0.000000e+00
61 62 7.105427e-15
62 63 0.000000e+00
63 64 0.000000e+00
64 65 0.000000e+00
65 66 0.000000e+00
66 67 0.000000e+00
67 68 0.000000e+00
68 69 0.000000e+00
69 70 0.000000e+00
70 71 0.000000e+00
71 72 0.000000e+00
72 73 0.000000e+00
73 74 0.000000e+00
74 75 0.000000e+00
75 76 0.000000e+00
76 77 0.000000e+00
77 78 1.421085e-14
78 79 0.000000e+00
79 80 0.000000e+00
80 81 0.000000e+00
81 82 0.000000e+00
82 83 0.000000e+00
83 84 0.000000e+00
84 85 0.000000e+00
85 86 0.000000e+00
86 87 0.000000e+00
87 88 0.000000e+00
88 89 0.000000e+00
89 90 0.000000e+00
90 91 0.000000e+00
91 92 0.000000e+00
92 93 1.421085e-14
93 94 1.421085e-14
94 95 1.421085e-14
95 96 0.000000e+00
96 97 0.000000e+00
97 98 0.000000e+00
98 99 0.000000e+00
99 100 0.000000e+00
Is there a pattern?
--
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it. ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
More information about the R-help
mailing list