### 8.4 Comparison Operators ¶

Comparison operators compare numeric values for relationships such as equality. They are written using relational operators.

All of Octave’s comparison operators return a value of 1 if the comparison is true, or 0 if it is false. For matrix values, they all work on an element-by-element basis. Broadcasting rules apply. See Broadcasting. For example:

    [1, 2; 3, 4] == [1, 3; 2, 4]
         ⇒   1  0
             0  1

According to broadcasting rules, if one operand is a scalar and the other is a matrix, the scalar is compared to each element of the matrix in turn, and the result is the same size as the matrix.

`x < y` ¶

  True if x is less than y.

`x <= y` ¶

  True if x is less than or equal to y.

`x == y` ¶

  True if x is equal to y.

`x >= y` ¶

  True if x is greater than or equal to y.

`x > y` ¶

  True if x is greater than y.

`x != y` ¶
`x ~= y`

  True if x is not equal to y.

For complex numbers, the following ordering is defined: z1 < z2 if and only if

      abs (z1) < abs (z2)
      || (abs (z1) == abs (z2) && arg (z1) < arg (z2))

This is consistent with the ordering used by max, min and sort, but is not consistent with MATLAB, which only compares the real parts.

String comparisons may also be performed with the `strcmp` function, not with the comparison operators listed above. See Strings.

`TF =` eq `(A, B)` ¶

  Return true if the two inputs are equal.

  This function is equivalent to `A == B`.

  See also: ne, isequal, le, ge, gt, ne, lt.

`TF =` ge `(A, B)` ¶

  This function is equivalent to `A >= B`.

  See also: le, eq, gt, ne, lt.

`TF =` gt `(A, B)` ¶

  This function is equivalent to `A > B`.

  See also: le, eq, ge, ne, lt.

`tf =` isequal `(x1, x2, …)` ¶

  Return true if all of x1, x2, … are equal.

  See also: isequaln.

`tf =` isequaln `(x1, x2, …)` ¶

  Return true if all of x1, x2, … are equal under the additional assumption that NaN == NaN (no comparison of NaN placeholders in dataset).

  See also: isequal.

`TF =` le `(A, B)` ¶

  This function is equivalent to `A <= B`.

  See also: eq, ge, gt, ne, lt.

`TF =` lt `(A, B)` ¶

  This function is equivalent to `A < B`.

  See also: le, eq, ge, gt, ne.

`TF =` ne `(A, B)` ¶

  Return true if the two inputs are not equal.

  This function is equivalent to `A != B`.

  See also: eq, isequal, le, ge, lt.