Skip to content
Myr

Remove decimal number text from v1.6 manual

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Aleksey Tsalolikhin · committed by William Langford · parent 2de3bc3 · Browse files · 1 file+0 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+0 added−47 removed

  • other:+0 added−47 removed

1 file+0 added−47 removed

modified:docs/content/manual/v1.6/manual.yml-47 removed
290 unmodified lines
291 Since jq by default pretty-prints all output, this trivial292 program can be a useful way of formatting JSON output from,293 say, `curl`.294295 An important point about the identity filter is that it 296 guarantees to preserve the literal decimal representation 297 of values. This is particularly important when dealing with numbers 298 which can't be losslessly converted to an IEEE754 double precision 299 representation.300301 jq doesn't truncate the literal numbers to double unless there302 is a need to make arithmetic operations with the number.303 Comparisons are carried out over the untruncated big decimal 304 representation of the number.305306 jq will also try to maintain the original decimal precision of the provided307 number literal. See below for examples. 308295 examples:296 - program: '.'297 input: '"Hello, world!"'298 output: ['"Hello, world!"']299314 - program: '. | tojson'315 input: '12345678909876543212345'316 output: ['"12345678909876543212345"']300318 - program: 'map([., . == 1]) | tojson'319 input: '[1, 1.000, 1.0, 100e-2]'320 output: ['"[[1,true],[1.000,true],[1.0,true],[1.00,true]]"']321322 - program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)'323 input: '10000000000000000000000000000001'324 output: ['[true, false]']325301 - title: "Object Identifier-Index: `.foo`, `.foo.bar`"302 body: |303304 The simplest *useful* filter is `.foo`. When given a
207 unmodified lines
512 values take an input and produce an output - `42` is a valid jq513 expression that takes an input, ignores it, and returns 42514 instead.515541 Numbers in jq are internally represented by their IEEE754 double 542 precision approximation. Any arithmetic operation with numbers, 543 whether they are literals or results of previous filters, will 544 produce a double precision floating point result.545546 However, when parsing a literal jq will store the original literal547 string. If no mutation is applied to this value then it will make548 to the output in its original form, even if conversion to double 549 would result in a loss. 550516 entries:517 - title: "Array construction: `[]`"518 body: |519
110 unmodified lines
630 etc.). However, jq never does implicit type conversions. If you631 try to add a string to an object you'll get an error message and632 no result.633669 Please note that all numbers are converted to IEEE754 double precision 670 floating point representation. Arithmetic and logical operators are working671 with these converted doubles. Results of all such operations are also limited 672 to the double precision. 673674 The only exception to this behaviour of number is a snapshot of original number 675 literal. When a number which originally was provided as a literal is never676 mutated until the end of the program then it is printed to the output in its 677 original literal form. This also includes cases when the original literal 678 would be truncated when converted to the IEEE754 double precision floating point679 number.680634 entries:635 - title: "Addition: `+`"636 body: |637
2652 unmodified lines