Merge 68bd122e5d53db1c83e3b0271875b9182354bce9 into d73189dd5a582c19c565774bd56fed4e72d33c99

This commit is contained in:
Jake Bailey 2026-05-21 23:26:22 -07:00 committed by GitHub
commit 18b6604239
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

6
dtoa.c

@ -1505,8 +1505,10 @@ double js_atod(const char *str, const char **pnext, int radix, int flags,
}
/* Use the extra digits for rounding if the base is a power of
two. Otherwise they are just truncated. */
if (radix_bits != 0 && extra_digits != 0) {
two. Otherwise use them as a sticky bit so that round-half-to-even
rounds correctly when there are non-zero digits beyond the
precision we kept. */
if (extra_digits != 0) {
tmp0->tab[0] |= 1;
}

@ -398,6 +398,12 @@ function test_number()
assert((1.3).toString(7), "1.2046204620462046205");
assert((1.3).toString(35), "1.ahhhhhhhhhm");
/* parsing must use digits beyond max_digits as a sticky bit so
that round-half-to-even rounds in the correct direction.
https://github.com/bellard/quickjs/issues/452 */
assert(+"100000000000000000000000.000000000000001",
1.0000000000000001e+23);
}
function test_eval2()