⚡️ Optimise the Zero Point Threshold in wad_exp#189
⚡️ Optimise the Zero Point Threshold in wad_exp#189pcaversaccio merged 5 commits intopcaversaccio:mainfrom engn33r:main
wad_exp#189Conversation
Signed-off-by: engn33r <engn33r@users.noreply.github.com>
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 / <pcaversaccio@users.noreply.github.com>
wad_expwad_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_expwad_exp
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
wad_expwad_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_551was 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