Ok, we all know javascript is terrible at math, decimals, multiplication, rounding. But I have never noticed it even is pretty terrible at adding simple decimals to a mere 1 decimal place. I would like to know why this is happening on a really trivial array sum, also rounding here is not an option to make all the troubles go away as I require accuracy. Second, can I get some recommendations on a decent math library as I'm sure the main answers will recommend one.
Heres a code pen to view javascript failing in action :) : https://codepen.io/anon/pen/jvyVzL
The code:
var sumList = [18.7, 29, 22.7, 0.3, 5.6, 17.5, 2.6, 2.6, 1]
function1 () {
return sumList.reduce((a, b) => a + b, 0)
}
// result: 99.99999999999999
// expected: 100