So, I have a Javascript script that adds small fragments together in a loop and its possible that it will add 0.2 to 0.1. Then this value is passed to another function, but the problem is that I need 0.3 to feed exactly, and not 0.30000000000000004.
What is the easiest way to provide the correct and accurate number. Please note that his ability to get 0.25 + 0.125, etc. Adding to just rounding to 1 decimal will not solve the problem.
It is also possible to add 0.2 + 0.10000000000000004, although this is very, very unlikely!
source share