Change value for short path to return zero in wadExp#405
Change value for short path to return zero in wadExp#405engn33r wants to merge 2 commits intotransmissions11:mainfrom
wadExp#405Conversation
|
interesting, nice find! cc @recmo — want to double check, does this look right to you? |
|
For reference, you can get this value in python (minus some precision) with |
|
This is where the original value came from: https://twitter.com/recmo/status/1744470975872127005 The rational approximation may go from 0 to 1 earlier or later than this exact value. Your unit tests seems to show B is the case, so it should be save to raise the limit. (Which means a smaller absolute value since it is negative.) (But this assumes that the rational approximation is monotonic, i.e. that it only transitions from 0 to 1 once. I did some empirical testing of this, but it is not exhaustive. So there is a very small chance that with this extra optimization it will now return 0 where it previously returned the more accurately rounded value of 1.) |
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
wadExp()and return zero. 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 currentwadExp()implementation transitions from 1 to zero.The change to CREATE3.t.sol is from the linter, not a change I deliberately made.
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge snapshot?npm run lint?forge test?Pull requests with an incomplete checklist will be thrown out.