Skip to content

fix math/number inconsistency - #348

Merged
jhnaldo merged 4 commits into
devfrom
fix-math-number-inconsistency
Jul 30, 2026
Merged

fix math/number inconsistency#348
jhnaldo merged 4 commits into
devfrom
fix-math-number-inconsistency

Conversation

@CodePsy-2001

Copy link
Copy Markdown

related issue: #338

Summary

Fix interpreter crashes when implementation-approximated math results become non-finite values such as Infinity or NaN.

The reported case was:

Math.pow.call(0, -0.1, -Number.MAX_VALUE);
Math.pow(2, Number.MAX_VALUE);
Math.exp(1000);
Math.expm1(1000);
Math.cosh(1000);
Math.sinh(1000);

This previously crashed because math.pow(...) could return Double.PositiveInfinity, which was then wrapped as Math(BigDecimal). BigDecimal cannot represent infinity.

Changes

  • Preserve non-finite results from mathematical approximation paths.
  • Convert extended mathematical infinities through [approx-number].
  • Avoid wrapping non-finite Double results as Math.
  • Add regression test.

EvalSmallTest passes.

@jhnaldo
jhnaldo force-pushed the fix-math-number-inconsistency branch from 9286371 to 065439e Compare July 30, 2026 02:23
@jhnaldo

jhnaldo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for fixing this! I added ExtMath to handle non-finite values properly and refactored the normalization logic for math and number results. Everything looks solid now, so I will go ahead and merge this PR.

@jhnaldo
jhnaldo merged commit 9ed19be into dev Jul 30, 2026
6 checks passed
@jhnaldo
jhnaldo deleted the fix-math-number-inconsistency branch July 30, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants