js-on-sx: js-num-from-string uses pow (float) for exponent
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m4s

js-pow-int 10 20 overflows int64 (10^20 > 2^63), so numeric literals
like 1e20 and 100000000000000000000 were parsing as
-1457092405402533888. The pow primitive uses float-domain
exponentiation and produces 1e+20 correctly. Single call swap in
js-num-from-string. built-ins/String (with --restart-every 1):
67/99 → 70/99. conformance.sh: 148/148.
This commit is contained in:
2026-05-07 13:42:32 +00:00
parent 66f13c95d5
commit c81e3f3705
4 changed files with 50 additions and 26 deletions

View File

@@ -1073,7 +1073,8 @@
((trimmed (js-trim s)))
(cond
((= trimmed "") 0)
((js-hex-prefix? trimmed) (js-parse-hex trimmed 2 0))
((js-hex-prefix? trimmed)
(js-parse-hex trimmed 2 0))
(else
(let
((esplit (js-find-exp-char trimmed)))
@@ -1082,12 +1083,28 @@
(let
((mant (js-string-slice trimmed 0 esplit))
(expstr
(js-string-slice trimmed (+ esplit 1) (len trimmed))))
(js-string-slice
trimmed
(+ esplit 1)
(len trimmed))))
(let
((m (js-parse-decimal mant 0 0 1 false 0))
(e (js-parse-decimal expstr 0 0 1 false 0)))
(* m (js-pow-int 10 e))))
(js-parse-decimal trimmed 0 0 1 false 0))))))))
(e
(js-parse-decimal
expstr
0
0
1
false
0)))
(* m (pow 10 e))))
(js-parse-decimal
trimmed
0
0
1
false
0))))))))
(define js-trim (fn (s) (js-trim-left (js-trim-right s))))