Skip to content

fix(jq): preserve fractional scalar precision - #305

Closed
efegokdemir wants to merge 1 commit into
cli:trunkfrom
efegokdemir:codex/issue-256-jq-precision
Closed

efegokdemir wants to merge 1 commit into
cli:trunkfrom
efegokdemir:codex/issue-256-jq-precision

Conversation

@efegokdemir

Copy link
Copy Markdown

Summary

jq.Evaluate currently formats non-integer scalar values with exactly two fractional digits, which turns values such as 0.001 into 0.00. This preserves the value's meaningful decimal representation instead.

Changes

  • Format floating-point scalar output with strconv.FormatFloat precision -1.
  • Add a regression test covering 0.001.

Testing

  • go test ./pkg/jq
  • go test ./...
  • git diff --check

All passed.

Notes

The issue is not duplicated by an existing open PR: the only open PR mentioning 256 is unrelated to this change. The approach follows the maintainer's issue discussion that the truncation is unexpected and should be fixed without changing the public API.

AI assistance was used to investigate the issue, implement the focused change, and run the tests. I reviewed the complete diff and am responsible for the submitted change.

Fixes #256

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>
@BagToad BagToad closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jq.Evaluate rounds non-integer numbers to 2 decimals (0.001 becomes 0.00)

2 participants