Documentation Source Text

Check-in [010e930cc2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved wording of the floatingpoint.html document.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 010e930cc22f67846dde5774233aa324e277b51f751906acc8f71066a633e947
User & Date: drh 2020-07-26 13:35:34.772
Context
2020-07-26
16:11
Merge branch-3.32 fixed into trunk. (check-in: ace42c454f user: drh tags: trunk)
13:35
Improved wording of the floatingpoint.html document. (check-in: 010e930cc2 user: drh tags: trunk)
13:24
Fix typos in the new floating point document. (check-in: e26caafc33 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to pages/floatingpoint.in.
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
<h3>Is it close enough?</h3>

<p>The precision provided by IEEE 754 Binary64 is sufficient for most computations.
For example, if "47.49" represents a price and inflation is running
at 2% per year, then the price is going up by about 0.0000000301 dollars per
second.  The error in the recorded value of 47.49 represents about 66 nanoseconds
worth of inflation.  So if the 47.49 price is exact
when you enter it, then the effects of inflation will cause the value actually stored

(47.4900000000000019895196601282805204391479492187) to be exact less than 
one ten-millionth of a second later.
Surely that level of precision is sufficient for most purposes?

<h1>Extensions For Dealing With Floating Point Numbers</h1>

<tcl>hd_fragment ieee754ext {ieee754 extension}</tcl>
<h2>The ieee754.c Extension</h2>








|
>
|
|







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<h3>Is it close enough?</h3>

<p>The precision provided by IEEE 754 Binary64 is sufficient for most computations.
For example, if "47.49" represents a price and inflation is running
at 2% per year, then the price is going up by about 0.0000000301 dollars per
second.  The error in the recorded value of 47.49 represents about 66 nanoseconds
worth of inflation.  So if the 47.49 price is exact
when you enter it, then the effects of inflation will cause the true value to
exactly equal the value actually stored
(47.4900000000000019895196601282805204391479492187) in less than 
one ten-millionth of a second.
Surely that level of precision is sufficient for most purposes?

<h1>Extensions For Dealing With Floating Point Numbers</h1>

<tcl>hd_fragment ieee754ext {ieee754 extension}</tcl>
<h2>The ieee754.c Extension</h2>

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<tcl>hd_fragment ieee754m {ieee754_mantissa() function} \
   {ieee754_exponent() function} </tcl>
<h3>The ieee754_mantissa() and ieee754_exponent() functions</h3>

<p>The text output of the one-argument form of ieee754() is great for human
readability, but it awkward to use as part of a larger expression.  Hence
The ieee754_mantissa() and ieee754_exponent() routines were added to return
respectively, the M and E values corresponding to their single argument F
value.
For example:

<codeblock>
sqlite> .mode box
sqlite> SELECT ieee754_mantissa(47.49) AS M, ieee754_exponent(47.49) AS E;
┌──────────────────┬─────┐







|







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<tcl>hd_fragment ieee754m {ieee754_mantissa() function} \
   {ieee754_exponent() function} </tcl>
<h3>The ieee754_mantissa() and ieee754_exponent() functions</h3>

<p>The text output of the one-argument form of ieee754() is great for human
readability, but it awkward to use as part of a larger expression.  Hence
The ieee754_mantissa() and ieee754_exponent() routines were added to return
the M and E values corresponding to their single argument F
value.
For example:

<codeblock>
sqlite> .mode box
sqlite> SELECT ieee754_mantissa(47.49) AS M, ieee754_exponent(47.49) AS E;
┌──────────────────┬─────┐
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
There is no division operator at this time.

<p>Use the decimal_cmp(A,B) to compare two decimal values.  The result will
be negative, zero, or positive if A is less than, equal to, or greater than B,
respectively.

<p>The decimal_sum(X) function is an aggregate, like the built-in
[sum() aggregate function] except that decimal_sum() computes its result
to arbitrary precision and is therefore precise.

<p>Finally, the decimal extension provides the "decimal" collating sequences
that compares decimal text strings in numeric order.

<h1>Techniques</h1>








|







288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
There is no division operator at this time.

<p>Use the decimal_cmp(A,B) to compare two decimal values.  The result will
be negative, zero, or positive if A is less than, equal to, or greater than B,
respectively.

<p>The decimal_sum(X) function is an aggregate, like the built-in
[sum() aggregate function], except that decimal_sum() computes its result
to arbitrary precision and is therefore precise.

<p>Finally, the decimal extension provides the "decimal" collating sequences
that compares decimal text strings in numeric order.

<h1>Techniques</h1>