MATLAB: 4.8/1.6 is not equal to 3

machine precisionmath operation

If I do these operations, I get two completely different results. Yet they could be operations that do not require checking of machine precision. How can this be remedied? Thank you.
>> (2*1.6)/1.6 == 2
ans =
logical
1
>> (3*1.6)/1.6 == 3
ans =
logical
0
>> (2*1.8)/1.8 == 2
ans =
logical
1
>> (3*1.8)/1.8 == 3
ans =
logical
1
My problem concerns the resolution of power flow problems in per-unit (p.u.) for which all numbers are in floating point. Since one of the constraints in solving these problems is that the sum of all the values present on a node of a network must be zero, because of these errors the sum is not always zero and this blocks some algorithms. In some cases, the problem was solved using ~= instead of == (1), but this can lead to other problems when the sum must be precisely ~= 0.
I was convinced that there was a way to eliminate this problem without having to think that the possible solution of a power flow problem could depend on the numbers involved or if the error in my answer is the result of round-off error or a bug. But I understood, thanks to the various references indicated, that this is not the case.

Best Answer

Here "==" is logical equality check, if the Left Hand Side equal to Right Hand side, it gives logical 1 (True), else 0
More about
>> 4.8/1.6
ans =
3.0000
>> ans==3
ans =
logical
0
Here floating point representation, is related to Precision, This is FAQ (Multiple Answered there)
More Detail (Detail Explanation by @Jan), also you can look here for Floating-Point Arithmetic in Matlab
Still any issue let us know?