0

I have the following issue.

After I extracted two values from the database, I performed a subtraction obtaining a precision issue.

For example, the two values extracted are:

Double a1 = rs.getDouble("A");  ---> 20.4
Double a2 = rs.getDouble("B");  ---> 15.4

and the subtraction returns

Double diff = a2 - a1;  ---> 4.999999999999998

My expected result was 5.0 obviously. How can I fix it?

Thanks

Fab
  • 1,145
  • 7
  • 20
  • 40

0 Answers0