KasparEtter / ef1p

Explained from First Principles is a technology, science, and philosophy blog for curious people who want to understand and change the world.
https://explained-from-first-principles.com
Creative Commons Attribution 4.0 International
117 stars 5 forks source link

Fix a bug in fast repetition non-recursive algo #7

Closed dbrans closed 1 year ago

KasparEtter commented 1 year ago

Hi, thanks a lot for trying to improve my article! I apologize for the late reply; I've been travelling. The published algorithm is correct (as far as I can tell). It's also how I implemented fast repetition for the tools. Maybe you're confusing it with the algorithm which evaluates the bits from "left to right". The algorithm you wanted to change, however, considers the least significant bits first. This is why we have to square/double a separate variable and then "mix it into the result variable" at the right places/magnitudes. (As I referenced in the article, there's a similar algorithm on Wikipedia).