Skip to content

NaN and the infinities

On 3.x a NaN or infinite parameter was bound as null (#344), a float divided by a float zero failed on Postgres and gave null on SQLite (#536), and toFloat('NaN') gave null (#573). They now give what Neo4j gives, on every SQL store:

RETURN 0.0 / 0.0, 1.0 / 0.0, $nan = $nan, toFloat('Infinity') // NaN, Infinity, false, Infinity
  • Parameters: a NaN or infinite parameter is bound, compared and added as itself (#344), and written as itself where the store holds it: see the breaking change above.
  • Arithmetic: a number divided or taken % by a float zero gives NaN or an infinity, as in Java, on Postgres and SQLite (#536); NaN is equal to nothing, itself included, on Oracle (#512); sum() and avg() of both infinities give NaN on SQLite (#579). Postgres still works float arithmetic out in exact decimal, so 0.1 + 0.2 is 0.3 there (Cypher on Oracle and Postgres).
  • Text: toFloat() reads NaN, Infinity and -Infinity as Java does (#573).
  • Storage: a NaN or an infinity a statement writes is kept, and read back as itself, on Oracle, and an infinity on SQLite.

The spec’s cases: “NaN and the infinities as parameters”, “NaN worked out”, “NaN and the infinities written”, “NaN worked out from stored infinities” and “NaN and the infinities given to SET and MERGE”.