Equality Operators
So far we've seen how to compare and see if values differ or match but we did not have a way to ask if not. In this sample we'll look into the equality operator (make it a bit more complex) and take a look at a new equality operator: the "is not equal": (!=).
In earlier videos, we came across all types of rational operators. But when we said equality operator, we just referred to (==). This is used to compare the equality of two variables and give the result. But there is another operator which is used to test the inequality of these two variables. This operator is referred as the "inequality operator" and the symbol to represent this operator is !=.
Test for Equality
Let us consider trace((a+b)==(c+5)), here a, b, c are the variables. a=5, b=6, c=-3. So the equation would result in trace(11==2), which is false. Hence, the application performs all mathematical operations before testing the equality of the equation. So == can be used to compare the equality for complicated equations as well.
Test for Inequality
This also works for inequality. We can check whether the first number is unequal to the second one or not. For example, if we have trace(a!=b), the output is true if the values of a and b are unequal and false if the values are equal. It is important to learn about this operator because we use the inequality condition in a few control statements for repetition of loops. As said earlier, detailed information about repetitive functions conditional statements will be provided later. This inequality operator can also be used to compare big and complicated equations. The application is good enough to first solve the equation on both sides and then compare the two sides to give out the Boolean result (true or false.)