This is the main mathematical problem with floating point.
Computers work with binary math. There are no problems for integer values. But for decimal places, he uses a technique called floating point math. The problem is that although floating points are good, they do not bind directly to decimal values; even relatively simple decimal values may not be possible to represent exactly in binary format.
If you always work with two decimal places - for example, for currencies - it is often better to understand your values as integers (for example, store cents, not dollars, or pence, not pounds), so that all your math is done using integers, and the results will be accurate. You only need a decimal value for the display, which you can do at the moment you need it.
source share