Can someone please explain why is this happening, the operators are adding numbers during the operation.

Itâ€™s down to the way floating point values are typically stored in computer memory and Floating-point arithmetic - Wikipedia. Storing infinite precision isnâ€™t possible, especially for irrational numbers like `pi`

and mathematical operations on floats often result in approximations.

For dealing with this a good option is to work with integers when performing mathematical operations (with currency for example use the smallest value e.g. cents instead of dollars) if at all possible. There may be some but less precision loss if you can refactor or use libraries to work with rational numbers most of the time (keeping exponent and quotient for division), or, in cases where youâ€™re performing only a few operations and arenâ€™t worried about the precision of the nth digit you can truncate/round the result in some way when printing.

Have a look for floating point (arithmetic) and Java in particular (itâ€™s not just Java affected but for what you want to do specifying the language is useful) and youâ€™ll find some excellent resources explaining and then trying to deal with this.

Thank you very much

Now I got it!