Skip to content

Commit

Permalink
Support parsing '-nan' (#3329)
Browse files Browse the repository at this point in the history
Due to usages of `sprintf(str, "%.15g", d);` when d is NaN.

From @LiorKogan: "We should treat `-nan` as `nan`".

References:
- RedisGraph/RedisGraph#2930
  • Loading branch information
sazzad16 authored Mar 22, 2023
1 parent fe96e93 commit 281003b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static Double parseFloatingPointNumber(String str) {
return Double.NEGATIVE_INFINITY;

case "nan":
case "-nan": // for some module commands // TODO: remove
return Double.NaN;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public void parseNaN() {
Record r = rs.iterator().next();
assertEquals(Double.NaN, r.getValue(0), 0d);
}

@Test
public void parseMinusNaN() {
ResultSet rs = client.graphQuery("db", "RETURN sqrt(-1)");
assertEquals(1, rs.size());
Record r = rs.iterator().next();
assertEquals(Double.NaN, r.getValue(0), 0d);
}
}

0 comments on commit 281003b

Please sign in to comment.