Comment by tasty_freeze
4 years ago
The thing that jumped out at me, as I've seen the same kind of thing on the job, is the assumption that, eg, log(1000)/log(10) is exactly 3. Does the standard guarantee that the rounded approximation of one transcendental number by the rounded approximation of a related transcendental number will give 3.0 and not 2.999999999?
Yeah that seems like a serious flaw to me too. On my Python:
But I don't know about the guarantees provided in the JavaScript standard (or more importantly those offered by actual browsers).
Floating point math is IEEE 754 in pretty much all cases, so you should see this result in most languages. `math.log(1000, 10)` gives the same result because it's implemented using natural logs internally as it is in most languages.
In this case, there's only about six boundary cases to consider so you can just manually verify it works as expected.