You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
castComparableNumber (and BinaryComparator) still lose precision for a Long/Float pair above 2^53 #7628
Follow-up from PR #7627 / issue #7614, found by CodeRabbit's review of that PR.
The remaining defect
#7614 fixed Type.castComparableNumber narrowing an Integer/Long to Float (losing precision above 2^24) by
promoting both operands to double instead - matching BinaryComparator.compareWideningLong's own widening, which
was the explicit goal (the two entry points must agree, per #7609).
That widening is itself lossy above 2^53 (Double's exact integer range): 10_000_000_000_000_001L.doubleValue()
rounds to the same double that widenFloat(1.0E16f) parses to, so castComparableNumber(10_000_000_000_000_001L, 1.0E16f) reports the pair equal via couple[0].equals(couple[1]) even though they are not. The symmetric Float/Long branch has the same defect.
This is narrower than the #7614 band (2^24 vs 2^53 - a long has to be quite large) but is the same shape.
Why it's a separate issue rather than a quick fix inside #7614's PR
Fixing only castComparableNumber (e.g. routing this specific band through BigDecimal) would reintroduce exactly
the divergence #7609/#7614 were about: BinaryComparator.compareWideningLong/compareNarrowIntegral would still
report ordering via lossy double, while equality would be exact - two entry points disagreeing on the same pair,
which is the failure mode this whole family of issues (#7609, #7613, #7614) exists to close. A correct fix has to
touch BinaryComparator too, and deserves its own regression test across the 2^53 boundary - the existing
49-pair sweep from PR #7612 covers precision loss above 2^24, not above 2^53.
Suggested fix
When a Long outside [-2^53, 2^53] meets a Float/Double, promote both to BigDecimal (via widenFloat's
decimal form for the float side) instead of double, in both Type.castComparableNumber and BinaryComparator.compareWideningLong/compareNarrowIntegral, so ordering and equality keep agreeing at every
magnitude.
Comparing a very large whole number against a FLOAT or DOUBLE could report them as equal when they are not. Both values were converted to double first, which stops being exact above 2^53, so a band of distinct numbers collapsed onto the same value. Such a pair is now compared exactly.
Three related problems in the same comparator turned up while fixing it, and are fixed too:
comparing a number against a DECIMAL could give contradictory answers depending on which side came first;
comparing a number against a DATETIME with second, microsecond or nanosecond precision always answered "less than", whatever the values were;
comparing a number against any date or timestamp column could throw an error instead of answering, depending on which Java date type the database was configured to return.
One related case is deliberately left for later and tracked in #7754: comparing a boolean against a date or timestamp still fails in one direction.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
Activity
fix: address CodeRabbit review of PR #7627 (property rename hardening)
fix(#7628): keep ordering and equality exact past 2^53, not just past…
fix(#7628): order the sub-millisecond timestamp types instead of answ…
fix(#7628/#7638): normalize temporal operands, and keep a projected a…
docs(#7628/#7632): say why isFinite is not used on the primitive path…
fix(#7628): give the DECIMAL arm the same temporal handling as the ot…
Merge pull request #7750 from ArcadeData/fix/issue-7628-7624-7632-763…
lvca commentedon Sep 17, 2026
Fixed in #7750.
Comparing a very large whole number against a
FLOATorDOUBLEcould report them as equal when they are not. Both values were converted todoublefirst, which stops being exact above 2^53, so a band of distinct numbers collapsed onto the same value. Such a pair is now compared exactly.Three related problems in the same comparator turned up while fixing it, and are fixed too:
DECIMALcould give contradictory answers depending on which side came first;DATETIMEwith second, microsecond or nanosecond precision always answered "less than", whatever the values were;One related case is deliberately left for later and tracked in #7754: comparing a boolean against a date or timestamp still fails in one direction.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(#12673): openCypher min(), max() and ORDER BY compare numbers by …