When using Math.pow
in Javascript, I am getting unexpected result. See my experiments. Used Chrome V: 79.0.3945.130, Console to get these results:
Math.pow(10, -1)
Expected: 0.1
, Result: 0.1
Math.pow(10, -2)
Expected: 00.1
, Result: 00.1
Math.pow(10, -3)
Expected: 000.1
, Result: 000.1
Math.pow(10, -4)
Expected: 0000.1
, Result: 0.00009999999999999999
Math.pow(10, -5)
Expected: 00000.1
, Result: 0.000009999999999999999
Math.pow(10, -6)
Expected: 000000.1
, Result: 000000.1
The case of -4 and -5 is making this unusable for me for the reason I wanted to use it. (offsetting numbers with a set decimal length for display)
Any way to ensure the "expected" behavior?