If I perform the following instructions in NodeJS:
> 4.676 - 0.001
4.675
> 4.678 - 0.001
4.677
> 4.677 - 0.001
4.675999999999999
Why is not it accurate like the others? Version Node JS is 8.11.1
If I perform the following instructions in NodeJS:
> 4.676 - 0.001
4.675
> 4.678 - 0.001
4.677
> 4.677 - 0.001
4.675999999999999
Why is not it accurate like the others? Version Node JS is 8.11.1
This is a rounding issue found in most computer science.
Here are 2 articles:
For now, use Number((4.677 - 0.001).toFixed(3)); to the precision you need.