I've noticed weird behavior when using .toFixed(i). I was trying to round (38.174999 * 100) and got weird results
console.log(`i: ${i} = `, (38.174999 * 10 ** 2).toFixed(i))
i: 1 = 3817.5
i: 2 = 3817.50
i: 3 = 3817.500
i: 4 = 3817.4999
i: 5 = 3817.49990
i: 6 = 3817.499900
i: 7 = 3817.4999000
i: 8 = 3817.49990000
i: 9 = 3817.499900000
i: 10 = 3817.4999000000
i: 11 = 3817.49990000000
i: 12 = 3817.499900000000
i: 13 = 3817.4998999999998
from 13 onward it's similar. Does anyone know reason and already tried to check what is going one according to JS spec http://www.ecma-international.org/ecma-262/#sec-number.prototype.tofixed
For all those that are marking this question as 0.1 + 0.2
problem it's not the same. Question is why .toFixed(13)
changes value in comparison to .toFixed(12)