Bit magic to find multiplicative inverse of integers #158
paul-tqh-nguyen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This line has a TODO comment requesting to conjure up some bit magic to calculate the multiplicative inverse of integers.
I might've found an approach with good results. It might be worth implementing.
It's demonstrated in this script (click to expand).
The contents of the generated CSV can be seen here (click to expand).
Here's a chart showing the performance of the bit magic vs using signed integer division:

It looks like we can save 1/3 of the time.
Beta Was this translation helpful? Give feedback.
All reactions