Skip to content

Conversation

@MaxGraey
Copy link
Member

Many browsers have fast paths for Math.pow if exponents is integer-like. But it leads to imprecisions like 10 ** 208 != 1e208 or 10 ** -5 != 1e-5. For avoid this in our constant folding special case I add some clever workaround. Also add tests.

For more info see this comment: https://bugzilla.mozilla.org/show_bug.cgi?id=1775254#c13

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@MaxGraey MaxGraey requested a review from dcodeIO June 29, 2022 11:51
@dcodeIO
Copy link
Member

dcodeIO commented Jun 29, 2022

Wdyt of moving the "accurate pow" to src/util/math as a helper? Seems good to do just to separate the relevant documentation out of the compiler itself :)

@MaxGraey MaxGraey merged commit ec0b0c8 into AssemblyScript:main Jun 29, 2022
@MaxGraey MaxGraey deleted the avoid-pow-precompute-invariants branch June 29, 2022 13:12
@MaxGraey MaxGraey mentioned this pull request Jun 29, 2022
2 tasks
MaxGraey added a commit that referenced this pull request Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants