#13985·neo4j

Negative zero compares as equal to 0.0 and strictly less than 0.0 at the same time

Author: ting668Created Sep 21, 2026Updated Sep 25, 2026
Labelsbugcypherteam-cypherGithub Issue

Reporter: ting668

Neo4j Version: 2026.08.1 (Community edition; also checked on 5.26.30, the current 5.26 LTS patch) Operating System: Linux (WSL2), inside a Docker container Installation Method: Docker image neo4j:2026.08.1 API/Driver: cypher-shell (Bolt, in-container)

Description

While testing Neo4j using an intuitive approach inspired by attribute constraints, I found that negative zero compares as equal to 0.0 and strictly less than 0.0 at the same time.

Cypher number equality treats -0.0 and 0.0 as equal — in IEEE-754 the sign of a zero is not significant. Whatever equality says, a strict less-than on the same pair must then be false: the two operators need to stay consistent over one totally ordered numeric domain. Here the same pair of values yields eq = TRUE and lt = TRUE simultaneously, which is self-contradictory, and the contradiction also leaks into row filtering: a node whose stored value is -0.0 passes a WHERE n.v < 0.0 filter.

Steps to reproduce

Note: The queries below are a minimized, simplified example reproducing the bug.

Buggy query (no data needed):

cypher
RETURN toFloat('-0.0') = 0.0 AS eq,
       toFloat('-0.0') < 0.0 AS lt;

Expected behavior

The two values are equal, so the equality holds and the strict comparison does not:

eq = TRUE, lt = FALSE

Actual behavior

Both comparisons hold at once (observed on 2026.08.1 and 5.26.30 via cypher-shell):

eq = TRUE, lt = TRUE

As a control, the individual pieces behave correctly:

cypher
RETURN toFloat('-0.0') = 0.0 AS eq_only;
WITH 0.0 AS z RETURN z < 0.0 AS plain_lt;
eq_only = TRUE

plain_lt = FALSE

This also affects queries over stored data. Setup and buggy query:

cypher
CREATE (:N {uid:'neg',v:-0.0});
CREATE (:N {uid:'pos',v:0.0});
CREATE (:N {uid:'one',v:1.0});

MATCH (n:N) WHERE n.v < 0.0 RETURN n.uid AS uid ORDER BY uid;

Expected behavior: none of the stored values -0.0, 0.0, 1.0 is strictly less than 0.0, so the query should return no rows:

(no rows)

Actual behavior: the node whose stored value is -0.0 passes the strict filter:

uid = "neg"

This suggests that the less-than comparison may be treating the sign of a zero as significant (ordering -0.0 before +0.0), while equality follows the usual numeric convention that the two zeros are equal, so the two operators disagree on the same pair of values.