Skip to content

JMESPath functions floor and ceil return integer#688

Merged
danielaparker merged 5 commits into
danielaparker:masterfrom
BartelNieuwenhuyse:bugfix/jmespath_floor-and-ceil-return-integer
Mar 21, 2026
Merged

JMESPath functions floor and ceil return integer#688
danielaparker merged 5 commits into
danielaparker:masterfrom
BartelNieuwenhuyse:bugfix/jmespath_floor-and-ceil-return-integer

Conversation

@BartelNieuwenhuyse
Copy link
Copy Markdown

JMESPath function floor and ceil return a json float number, while the specs and the examples in it suggest that an integer should be returned.

Expected:
floor(`3.7`) -> 3
Actual:
floor(`3.7`) -> 3.0

Comment thread include/jsoncons_ext/jmespath/jmespath.hpp Outdated
@danielaparker
Copy link
Copy Markdown
Owner

danielaparker commented Mar 18, 2026

The cases that fail are failing because a double doesn't have enough precision to represent std::numeric_limits<int64_t>::max() exactly. The upper bound for preserving precision exactly is std::pow(2, std::numeric_limits<double>::digits). Numbers above that limit should remain in double representation. double values above that bound can't be sensibly cast to int types.

@BartelNieuwenhuyse BartelNieuwenhuyse marked this pull request as ready for review March 20, 2026 08:11
@danielaparker danielaparker merged commit 4ee8e34 into danielaparker:master Mar 21, 2026
37 checks passed
@danielaparker
Copy link
Copy Markdown
Owner

I think this is fine, thanks!

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.

2 participants