-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
⚡️ Optimise the Zero Point Threshold in wad_exp
#189
Conversation
Signed-off-by: engn33r <[email protected]>
wad_exp
@engn33r great catch! The original number stems from Remco's article: https://xn--2-umb.com/22/exp-ln/index.html. Can you please adjust the tests accordingly: - assertEq(math.wad_exp(-42_139_678_854_452_767_551), 0);
+ assertEq(math.wad_exp(-41_446_531_673_892_822_313), 0);
+ assertEq(math.wad_exp(-41_446_531_673_892_822_312), 1); and also update the |
FWIW, I already shared it with @Vectorized! |
@engn33r Beautiful optimization! |
Solmate PR and solady PR created |
Sweet, will merge tomorrow (busy day due to Ledger...) |
Signed-off-by: sudo rm -rf --no-preserve-root / <[email protected]>
wad_exp
wad_exp
For anyone who wants to understand how to replicate this using Titanoboa, here a step-by-step guide: ~$ pip install git+https://github.com/vyperlang/titanoboa
~$ git clone https://github.com/pcaversaccio/snekmate.git
~$ cd snekmate/src/utils/
~$ python
>>> import boa
>>> c = boa.load("Math.vy")
>>> c.wad_exp(-41_446_531_673_892_822_312)
1
>>> c.wad_exp(-41_446_531_673_892_822_313)
0 |
wad_exp
wad_exp
Signed-off-by: Pascal Marco Caversaccio <[email protected]>
Signed-off-by: Pascal Marco Caversaccio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx @engn33r!
wad_exp
wad_exp
✅ PR Checklist
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
wad_exp()
and return zero. I am not sure how the previously chosen value of-42_139_678_854_452_767_551
was selected, but these tests demonstrate the actual turning point when the result of the currentwad_exp()
implementation transitions from 1 to zero.🐶 Cute Animal Picture