I am trying to subtract one double value with another but I am getting an invalid result. The result for 4.15 - 0.2 works but fails for 4.14 and 4.13.
Double value conversion issue
Double
represents values in binary floating point system.
So, every programming language may show the same results.
One way would be showing the result with proper rounding.
Another might be using Decimal
instead of Double
.
But which would be better depends on your use case.
This may help you: