jq large-integer subtraction: keeping raw numbers in the team handover
A small difference can still be wrong when its inputs are large integers. Preserve the original numbers because precision may be lost before subtraction.
jq large-integer subtraction: keeping raw numbers in the team handover
Subtracting large integers in a log can hide low-digit loss behind a plausible-looking difference. Discarding the inputs and retaining only the delta makes the precision boundary difficult to inspect. Preserve raw integer representations alongside an independent difference to reconcile the actual arithmetic contract. [1, 2, 3]
What the primary source establishes
A short jq 1.8.1 report gives a large-integer subtraction result differing from bc's integer calculation. It highlights the need to check the exactness contract across both parsing and subtraction. [1]
The handover decision
Log collectors and analysts should retain raw integer strings and reconcile the tool's delta with an independently computed integer delta. Keep start_decimal, end_decimal, exact_delta, and tool_delta together rather than asking a downstream consumer to diagnose a difference after the inputs have been discarded. [1, 3]
A reference defined before the output
The illustrative reference subtracts 1773942159695413449 from 1773942167980555584 using integer arithmetic, yielding 8285142135. The normal delta is 8285142135; 8285142016 is the counterexample. These values define an exact subtraction comparison, not a new measurement of an operational latency incident. [1, 3]
The scoped Truthound check
Truthound Core 3.3.2 can compare exact_delta from independent integer arithmetic with tool_delta using ColumnPairValidator. A reference calculated after the raw integers have already been approximated is not independent. Attach a unit only after confirming it in the source contract. [1, 2, 3]
Limits and alternative choices
The report does not specify the numbers' business unit, so it does not establish a real nanosecond-log incident. Calculate the difference with an exact-integer path, then convert into the required display unit. If the source is already approximate, later exact subtraction cannot restore precision that was previously lost. [1, 3]
Application conditions
Retain original integer strings and independently compute the reference difference before comparing tool output.
Alternatives
Calculate the difference with an exact-integer path, then convert into the required display unit.
Limitations
The report does not specify the numbers' business unit, so it does not establish a real nanosecond-log incident.
Evidence
- Event checked
- Subject checked
- Modified
