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
Add a Comment
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 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.
Yes you were right. I tried it with VS and it was returning what Xcode did. Thanks for the response :)
This may help you:
This helps. Thank you :)