I've been investigating some rounding oddities in JavaScript stemming from their floating point implementation:
> Number(Math.round(1.005*100)/100);
1
I understand this is rounded down because the floating point representation of (1.005 * 100) is 100.49999999999999
But when I do this:
> Number(Math.round(1.005e2)+'e-2');
1.01
or more succinctly:
>1.005e2;
100.5
I get the expected (unexpected!) result. Why does JavaScript evaluate (1.005e2) as 100.5? Is it using another primitive type behind the scenes or is this a result of string parsing?
If anyone can point me to a spec about e notation implementation, I would be grateful!