News for hackers. Stuff that matters.
Re:Divisible by 7 (2016) by slver on Thursday May 20, 2021 @02:20PM (#27225017)
You 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...

Re:Divisible by 7 (2016) by gpvos on Thursday May 20, 2021 @02:37PM (#27225250)
I'm fairly sure holistio means doing a long division using pen and paper, or even off the top of their head.
Re:Divisible by 7 (2016) by KMnO4 on Thursday May 20, 2021 @02:44PM (#27225355)
Here’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