From: Fabrice Bellard Date: Mon, 23 Nov 2026 12:57:27 +0000 (+0100) Subject: fixed Math.sumPrecise X-Git-Url: https://git.kaiwu.me/http/ngx_http_proxy_module.html?a=commitdiff_plain;h=0a0f81743db048400ef6c9a2faf53245d2b16b1e;p=quickjs.git fixed Math.sumPrecise --- diff --git a/quickjs.c b/quickjs.c index 7d48a7d..a2e0b7f 100644 --- a/quickjs.c +++ b/quickjs.c @@ -49962,7 +49962,7 @@ typedef enum { /* we add one extra limb to avoid having to test for overflows during the sum */ #define SUM_PRECISE_ACC_LEN 39 -#define SUM_PRECISE_COUNTER_INIT 250 +#define SUM_PRECISE_COUNTER_INIT 126 typedef struct { SumPreciseStateEnum state; diff --git a/tests/test_builtin.js b/tests/test_builtin.js index 9c647d1..64c21fc 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -421,6 +421,7 @@ function test_math() assert(Math.hypot(3, 4), 5); assert(Math.abs(Math.hypot(3, 4, 5) - 7.0710678118654755) <= 1e-15); assert(Math.sumPrecise([1,Number.EPSILON/2,Number.MIN_VALUE]), 1.0000000000000002); + assert(Math.sumPrecise(new Array(300).fill(Math.pow(2,53)-1)), 2702159776422297000); } function test_number()