Make tests pass when --disable-decnum

This commit is contained in:
Nicolas Williams authored and Nico Williams committed 2024-05-15 12:48:00 -05:00
1 parent c1276169d6
commit 6d02d53f51
8 files changed
+88 -37

No files matched your search

Generated
+21 -9
View File
@@ -1,5 +1,5 @@
.
.TH "JQ" "1" "March 2024" "" ""
.TH "JQ" "1" "May 2024" "" ""
.
.SH "NAME"
\fBjq\fR \- Command\-line JSON processor
@@ -286,13 +286,16 @@ Although the identity filter never modifies the value of its input, jq processin
produces \fB1\.7976931348623157e+308\fR 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
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:
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\. Moreover, build configuration options can alter how jq processes numbers\.
.
.P
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
(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
(2) jq will attempt to maintain the original decimal precision of number literals, but in expressions such \fB1E1234567890\fR, precision will be lost if the exponent is too large\.
(2) jq will attempt to maintain the original decimal precision of number literals (if the \fB\-\-disable\-decnum\fR build configuration option was not used), but in expressions such \fB1E1234567890\fR, precision will be lost if the exponent is too large\.
.
.P
(3) In jq programs, a leading minus sign will trigger the conversion of the number to an IEEE754 representation\.
@@ -300,6 +303,9 @@ The way in which jq handles numbers has changed over time and further changes ar
.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
The examples below use the builtin function \fBhave_decnum\fR in order to demonstrate the expected effects of using / not using the \fB\-\-disable\-decnum\fR build configuration option, and also to allow automated tests derived from these examples to pass regardless of whether that option is used\.
.
.IP "" 4
.
.nf
@@ -312,21 +318,21 @@ jq \'\.\'
0\.12345678901234567890123456789
=> 0\.12345678901234567890123456789
jq \'[\., tojson]\'
jq \'[\., tojson] | \. == if have_decnum then [12345678909876543212345,"12345678909876543212345"] else [12345678909876543000000,"12345678909876543000000"] end\'
12345678909876543212345
=> [12345678909876543212345,"12345678909876543212345"]
=> true
jq \'\. < 0\.12345678901234567890123456788\'
0\.12345678901234567890123456789
=> false
jq \'map([\., \. == 1]) | tojson\'
jq \'map([\., \. == 1]) | tojson | \. == if have_decnum then "[[1,true],[1\.000,true],[1\.0,true],[1\.00,true]]" else "[[1,true],[1,true],[1,true],[1,true]]" end\'
[1, 1\.000, 1\.0, 100e\-2]
=> "[[1,true],[1\.000,true],[1\.0,true],[1\.00,true]]"
=> true
jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000)\'
jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000) | \. == if have_decnum then [true, false] else [false, false] end\'
10000000000000000000000000000001
=> [true, false]
=> true
.
.fi
.
@@ -2176,6 +2182,12 @@ jq \'walk( if type == "object" then with_entries( \.key |= sub( "^_+"; "") ) els
.
.IP "" 0
.
.SS "have_literal_numbers"
This builtin returns true if jq\'s build configuration includes support for preservation of input number literals\.
.
.SS "have_decnum"
This builtin returns true if jq was built with "decnum", which is the current literal number preserving numeric backend implementation for jq\.
.
.SS "$JQ_BUILD_CONFIGURATION"
This builtin binding shows the jq executable\'s build configuration\. Its value has no particular format, but it can be expected to be at least the \fB\./configure\fR command\-line arguments, and may be enriched in the future to include the version strings for the build tooling used\.
.