I know that for getting a 10 based logarithm I have to use Math.log() divided by the constant of the natural logarithm of 10.
var e1000 = Math.log(1000) / Math.LN10;
// Result: 2.9999999999999996 instead of
// expected 3.
console.log(e1000);
// Result: 999.999999999999 instead of
// expected 1000.
console.log(Math.pow(10, e1000));
BUT: The result is just an approximation. If I use the calculated value in further calculation the inaccuracy becomes worse.
Am I doing something wrong? Is there are more elegant way around it then just using Math.ceil()?