Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/jsoncons_ext/jmespath/jmespath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,8 @@ namespace detail {
template <typename Json>
class jmespath_evaluator
{
static constexpr double max_double_to_int64 = 9223372036854775807.0;
static constexpr double min_double_to_int64 = -9223372036854775808.0;
static constexpr double max_double_to_int64 = static_cast<double>(uint64_t(1u) << std::numeric_limits<double>::digits); // 2^53
static constexpr double min_double_to_int64 = -static_cast<double>(uint64_t(1u) << std::numeric_limits<double>::digits); // -2^53

public:
typedef typename Json::char_type char_type;
Expand Down
21 changes: 18 additions & 3 deletions test/jmespath/input/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,24 @@
"result": "-3"
},
{
"comment": "Ceil function applied to a large double not in int64_t range should return as double",
"expression": "ceil(`1e20`)",
"result": 1e20
"comment": "Value at 2^53 boundary (max safe integer)",
"expression": "ceil(`9007199254740992.0`)",
"result": 9007199254740992
},
{
"comment": "Negative value at -2^53 boundary",
"expression": "floor(`-9007199254740992.0`)",
"result": -9007199254740992
},
{
"comment": "Value beyond safe range remains as double (does not overflow to negative integer)",
"expression": "ceil(`9223372036854775807.2`)",
"result": 9.223372036854776e+18
},
{
"comment": "Negative value beyond safe range remains as double",
"expression": "floor(`-9223372036854775808.2`)",
"result": -9.223372036854776e+18
}
]
}
Expand Down