4 ms·
As the very first article says: > You can multiply two numbers by adding their exponents. So just with the exponent-addition you will be within a factor of 2 o
by advisedwang 2y ago
As the very first article says:
> 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?
- zahlman 2y agoYou can multiply two numbers by multiplying their mantissas and adding their exponents. Since the numbers are stored in base 2, the mantissa values range from 1 to 2 (subnormals notwithstanding) - but they're effectively stored as a 0..1 value. The effective range produced by adding vs. multiplying them have considerable overlap, and on average the difference won't be much. Because of how the mantissa and exponent fields are arranged (a deliberate choice by the standard, AFAIK), the mantissa effectively adds additional bits to the approximation of the logarithm given by the exponent. Edit: this other comment chain https://news.ycombinator.com/item?id=43034230 https://news.ycombinator.com/item?id=43034230 perhaps puts it better.