"deps/vscode:/vscode.git/clone" did not exist on "e4b0c8ec50f2248286b770a655ea85d5cfcc79f4"
Commit 7764996b authored by Guy Benoish's avatar Guy Benoish Committed by antirez
Browse files

Make sure Redis does not reply with negative zero

parent eba28e2c
...@@ -602,6 +602,10 @@ int ld2string(char *buf, size_t len, long double value, ld2string_mode mode) { ...@@ -602,6 +602,10 @@ int ld2string(char *buf, size_t len, long double value, ld2string_mode mode) {
} }
if (*p == '.') l--; if (*p == '.') l--;
} }
if (l == 2 && buf[0] == '-' && buf[1] == '0') {
buf[0] = '0';
l = 1;
}
break; break;
default: return 0; /* Invalid mode. */ default: return 0; /* Invalid mode. */
} }
......
...@@ -151,4 +151,10 @@ start_server {tags {"incr"}} { ...@@ -151,4 +151,10 @@ start_server {tags {"incr"}} {
catch {r incrbyfloat foo 1} err catch {r incrbyfloat foo 1} err
format $err format $err
} {ERR*valid*} } {ERR*valid*}
test {No negative zero} {
r incrbyfloat foo [expr double(1)/41]
r incrbyfloat foo [expr double(-1)/41]
r get foo
} {0}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment