Math.pow(3, -222)
gives 1.199724291183359e-106
5 + Math.pow(3, -222)
gives 5 !
i have tried to use parseFloat() and also toPrecision() but nothing happened
Math.pow(3, -222)
gives 1.199724291183359e-106
5 + Math.pow(3, -222)
gives 5 !
i have tried to use parseFloat() and also toPrecision() but nothing happened
This is because IEEE floats are very precise close to zero. The farther away from zero you get, the less precise you can be.
3^-222 is so small that, when added to 5, it is rounded down to zero.
5+3^-222 doesn't exist as a float, and is closer to 5 than it is the smallest number above 5, so it's rounded down to 5.