3 ms·
> Division is much slower than multiplication (unless using approximation). Dividing many numbers with one number can be optimized by firstly computing reciproc
by busymom0 1y ago
> Division is much slower than multiplication (unless using approximation). Dividing many numbers with one number can be optimized by firstly computing reciprocal then multiply by reciprocal.
Is this a general fact or specific to a language?
- whobre 1y agoIt's generally true even for CPU instructions: https://electronics.stackexchange.com/questions/280673/why-does-hardware-division-take-much-longer-than-multiplication https://electronics.stackexchange.com/questions/280673/why-d...
- ethan_smith 1y agoIt's hardware-level - division requires more CPU cycles than multiplication on most processor architectures, making this optimization pattern relevant across virtually all programming languages.