Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Optimize zero point in expWad #757

Merged
merged 1 commit into from
Dec 14, 2023
Merged

⚡️ Optimize zero point in expWad #757

merged 1 commit into from
Dec 14, 2023

Conversation

engn33r
Copy link
Contributor

@engn33r engn33r commented Dec 14, 2023

Description

This is the same optimization described in pcaversaccio/snekmate#189

This PR is for a very small optimization that is possible by increasing the range of values that will take the short logic path of expWad() and return 0. I am not sure how the previously chosen value of -42139678854452767551 was selected, but these tests demonstrate the actual turning point when the result of the current expWad() implementation transitions from 1 to 0.

function testExpWad() public {
    assertEq(FixedPointMathLib.expWad(-41446531673892822312), 1);
    assertEq(FixedPointMathLib.expWad(-41446531673892822313), 0);
}

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Ran forge fmt?
  • Ran forge snapshot?
  • Ran forge test?

Pull requests with an incomplete checklist will be thrown out.

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