diff options
author | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2023-07-20 03:37:30 +0000 |
---|---|---|
committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2023-07-20 03:37:30 +0000 |
commit | 6affc8ffd776d49616eb12441c82d79c06c4853b (patch) | |
tree | 95cb451bb2b6f74e8d8282ac8d7b46ff1f6b5d74 | |
parent | 705bdd465ad228e7c8fe4a54796720ccd7b4a6de (diff) |
Update website
-rw-r--r-- | manual/index.html | 82 |
1 files changed, 64 insertions, 18 deletions
diff --git a/manual/index.html b/manual/index.html index 1ecf4db3..2763e3a2 100644 --- a/manual/index.html +++ b/manual/index.html @@ -387,23 +387,41 @@ using some command-line options:</p> Identity: <code>.</code> </h3> - <p>The absolute simplest filter is <code>.</code> . This is a filter that -takes its input and produces it unchanged as output. That is, -this is the identity operator.</p> -<p>Since jq by default pretty-prints all output, this trivial -program can be a useful way of formatting JSON output from, -say, <code>curl</code>.</p> -<p>An important point about the identity filter is that it -guarantees to preserve the literal decimal representation -of values. This is particularly important when dealing with numbers -which can't be losslessly converted to an IEEE754 double precision + <p>The absolute simplest filter is <code>.</code> . This filter takes its +input and produces the same value as output. That is, this +is the identity operator.</p> +<p>Since jq by default pretty-prints all output, a trivial +program consisting of nothing but <code>.</code> can be used to format +JSON output from, say, <code>curl</code>.</p> +<p>Although the identity filter never modifies the value of its +input, jq processing can sometimes make it appear as though +it does. For example, using the current implementation of +jq, we would see that the expression:</p> +<pre><code>`1E1234567890 | .` +</code></pre> +<p>produces <code>1.7976931348623157e+308</code> on at least one platform. +This is because, in the process of parsing the number, this +particular version of jq has converted it to an IEEE754 +double-precision representation, losing precision.</p> +<p>The way in which jq handles numbers has changed over time +and further changes are likely within the parameters set by +the relevant JSON standards. The following remarks are +therefore offered with the understanding that they are +intended to be descriptive of the current version of jq and +should not be interpreted as being prescriptive:</p> +<p>(1) Any arithmetic operation on a number that has not +already been converted to an IEEE754 double precision +representation will trigger a conversion to the IEEE754 representation.</p> -<p>jq doesn't truncate the literal numbers to double unless there -is a need to make arithmetic operations with the number. -Comparisons are carried out over the untruncated big decimal -representation of the number.</p> -<p>jq will also try to maintain the original decimal precision of the provided -number literal. See below for examples.</p> +<p>(2) jq will attempt to maintain the original decimal +precision of number literals, but in expressions such +<code>1E1234567890</code>, precision will be lost if the exponent is +too large.</p> +<p>(3) In jq programs, a leading minus sign will trigger the +conversion of the number to an IEEE754 representation.</p> +<p>(4) Comparisons are carried out using the untruncated +big decimal representation of numbers if available, as +illustrated in one of the following examples.</p> <div> @@ -429,7 +447,21 @@ number literal. See below for examples.</p> </table> <table> - <tr><th></th><td class="jqprogram">jq '. | tojson'</td></tr> + <tr><th></th><td class="jqprogram">jq '.'</td></tr> + <tr><th>Input</th><td>0.12345678901234567890123456789</td></tr> + + + <tr> + + <th>Output</th> + + <td>0.12345678901234567890123456789</td> + </tr> + + </table> + + <table> + <tr><th></th><td class="jqprogram">jq '[., tojson]'</td></tr> <tr><th>Input</th><td>12345678909876543212345</td></tr> @@ -437,7 +469,21 @@ number literal. See below for examples.</p> <th>Output</th> - <td>"12345678909876543212345"</td> + <td>[12345678909876543212345,"12345678909876543212345"]</td> + </tr> + + </table> + + <table> + <tr><th></th><td class="jqprogram">jq '. < 0.12345678901234567890123456788'</td></tr> + <tr><th>Input</th><td>0.12345678901234567890123456789</td></tr> + + + <tr> + + <th>Output</th> + + <td>false</td> </tr> </table> |