The == operator tests equality. if (x == 5) checks if x equals 5. If true, the condition executes. Do not confuse == with =, which assigns values. The != operator tests inequality.
if (x != 0) runs when x is any value except 0. This is equivalent to if (!(x == 0)) but more readable. Comparing floating-point with == fails due to precision errors. double a = 0.1 + 0.2; if (a == 0.3) may be false.
Use a tolerance: if (abs(a - 0.3) < 0.0001).