3 ms·
It's math and not just for integers. That's also how slide rule works. a×b = 10^(log(a×b)) log(a×b) = log(a)+log(b) thus a×b = 10^(log(a)+log(b))
by nabla9 2y ago
It's math and not just for integers. That's also how slide rule works.
a×b = 10^(log(a×b))
log(a×b) = log(a)+log(b)
thus a×b = 10^(log(a)+log(b))
- Sharlin 2y agoYes, but what is nontrivial here is how good the approximation is, despite the mantissa part being linear (much better than the upper bound of being within 2x of the real value).
- shiandow 2y agoNontrivial yes, but it's not that complicated to figure out that floats are a piecewise linear approximation of the base 2 logarithm. Edit: or base 2^k, depends a bit how you view it.
- advisedwang 2y agoThe very first paragraph of the article says this and then goes on to say the trick gets the mantissa roughly right too: > You can multiply two numbers by adding their exponents. So just with the exponent-addition you will be within a factor of 2 of the right result. But this will actually be much better and get within 7.5% of the right answer. Why?