Skip to content

Commit ab9935e

Browse files
committedDec 28, 2018
Update the book
1 parent 84d77cf commit ab9935e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎docs/r-objects.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ <h3><span class="header-section-number">5.1.2</span> Integers</h3>
416416
<span class="kw">typeof</span>(int)
417417
## &quot;integer&quot;</code></pre>
418418
<p>Note that R won’t save a number as an integer unless you include the <code>L</code>. Integer numbers without the <code>L</code> will be saved as doubles. The only difference between <code>4</code> and <code>4L</code> is how R saves the number in your computer’s memory. Integers are defined more precisely in your computer’s memory than doubles (unless the integer is <em>very</em> large or small).</p>
419-
<p>Why would you save your data as an integer instead of a double? Sometimes a difference in precision can have surprising effects. Your computer allocates 64 bits of memory to store each double in an R program. This allows a lot of precision, but some numbers cannot be expressed exactly in 64 bits, the equivalent of a sequence of 64 ones and zeroes. For example, the number latexmath:<span class="math inline">\(\pi\)</span> contains an endless sequences of digits to the right of the decimal place. Your computer must round <span class="math inline">\(\pi\)</span> to something close to, but not exactly equal to <span class="math inline">\(\pi\)</span> to store <span class="math inline">\(\pi\)</span> in its memory. Many decimal numbers share a similar fate.</p>
419+
<p>Why would you save your data as an integer instead of a double? Sometimes a difference in precision can have surprising effects. Your computer allocates 64 bits of memory to store each double in an R program. This allows a lot of precision, but some numbers cannot be expressed exactly in 64 bits, the equivalent of a sequence of 64 ones and zeroes. For example, the number <span class="math inline">\(\pi\)</span> contains an endless sequences of digits to the right of the decimal place. Your computer must round <span class="math inline">\(\pi\)</span> to something close to, but not exactly equal to <span class="math inline">\(\pi\)</span> to store <span class="math inline">\(\pi\)</span> in its memory. Many decimal numbers share a similar fate.</p>
420420
<p>As a result, each double is accurate to about 16 significant digits. This introduces a little bit of error. In most cases, this rounding error will go unnoticed. However, in some situations, the rounding error can cause surprising results. For example, you may expect the result of the expression below to be zero, but it is not:</p>
421421
<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">sqrt</span>(<span class="dv">2</span>)<span class="op">^</span><span class="dv">2</span> <span class="op">-</span><span class="st"> </span><span class="dv">2</span>
422422
## 4.440892e-16</code></pre>

‎docs/search_index.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.