8 ms·
Clever and all, but I still actually divide faster than using this mechanism.
by holistio 5y ago
Clever and all, but I still actually divide faster than using this mechanism.
- slver 5y agoYou divide faster thanks to your language interpreters and compilers implementing thousands of algorithms like this which convert between arithmetic operations so you can have that speed. For example sometimes when you divide by specific numbers in C it gets compiled to equivalent multiplication and addition. Your comment reminds me of this other thread, where people were bragging they could implement curl in a few lines of Python code, by first including a CURL-like module...
- gpvos 5y agoI'm fairly sure holistio means doing a long division using pen and paper, or even off the top of their head.
- KMnO4 5y agoHere’s a cool video that shows how compilers optimize exponentiation[1]. It seems like a really simple problem on the surface (x^3? Just do xxx), but lots of smart people have thought hard about the best way to do it for any arbitrary exponent. For example, x^15 only needs 5 multiplication instructions. [1]: https://youtu.be/BfNlzdFa_a4 https://youtu.be/BfNlzdFa_a4