From: Andrey Zelenkov Date: Wed, 7 Jun 2017 13:36:13 +0000 (+0300) Subject: Fixed zero basis handling for scientific notation. X-Git-Tag: 0.1.11~25 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=48bf7240983a0155a0619af1561d8835843eaecd;p=njs.git Fixed zero basis handling for scientific notation. --- diff --git a/njs/njs_number.c b/njs/njs_number.c index cd1179f3..039c9c58 100644 --- a/njs/njs_number.c +++ b/njs/njs_number.c @@ -154,8 +154,10 @@ njs_number_dec_parse(u_char **start, u_char *end) p++; } - exponent = minus ? -exponent : exponent; - num = num * pow(10.0, exponent); + if (num != 0) { + exponent = minus ? -exponent : exponent; + num = num * pow(10.0, exponent); + } } } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index ff2e963b..0639da4f 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -191,6 +191,12 @@ static njs_unit_test_t njs_test[] = { nxt_string("1.0e308"), nxt_string("1e+308") }, + { nxt_string("0e309"), + nxt_string("0") }, + + { nxt_string("0e-309"), + nxt_string("0") }, + { nxt_string("1e"), nxt_string("SyntaxError: Unexpected token \"e\" in 1") },