Hello.
An issue is Java uses
IEEE 754[
^] standard. Consider not to use
float, use
double instead. When one uses floating point numbers he should be careful.
For further details please see
What Every Computer Scientist Should Know About Floating-Point Arithmetic[
^]
As for your question... You should use some round operations or to manipulate values with help of
BigDecimal[
^] or something like that.
BigDecimal a = new BigDecimal("2.3");
BigDecimal b = new BigDecimal("1.2");
BigDecimal c = a.subtract(b);
Please follow
this link[
^] for other cases.
Good luck.