In my app i am using this to calculate a number:
double result = ((a * a) + (b * b) - (2 * a * b));
If a for example a = 2 and b = 3.9, then the result should be 3.61. However, when I display “result” i get the number 3.610000000000001.
What is wrong here? How can I correct this error?
You can format your output value by using the following construct:
After this, in result you will have your value in X.XX format