My app is facing some issues with some adding, subtracting, and multiplication errors when adding the same number to itself over and over. I can add numbers such as 1.5 to 1.5, but for some reason once I start using numbers such as 3.99, after a few operations of addition or subtraction, it bugs out and outputs numbers such as 19.950000000000003
.
I solved the problem above by measuring the length after the .
then splitting the string. However now I am getting another problem, where sometimes if you start off with 9 * 3.99
or something alike, then you subtract 3.99 over and over, sometimes it results in the following chain
35.91
-> 31.92
-> 27.93
-> 23.93
This should not be happening because from 27.93
it should have went to 23.94
.
Could anyone help me with these problems, and maybe suggest a better way to deal with the adding/multiplication problem besides splitting the string that is displayed?