8.5.10   Comparison Operations

In HDevelop, the comparison operations are defined not only on atomic values, but also on tuples with an arbitrary number of elements. They always return values of type boolean. Table 8.15 shows all comparison operations.

Operation Meaning HALCON operator Alternative notation

t1 < t2 less than tuple_less
t1 > t2 greater than tuple_greater
t1 <= t2 less or equal tuple_less_equal
t1 >= t2 greater of equal tuple_greater_equal
t1 == t2 equal tuple_equal t1 = t2 (legacy)
t1 != t2 not equal tuple_not_equal t1 # t2 (legacy)

Table 8.15: Comparison operations.

t1 == t2 and t1 != t2 are defined on all types. Two tuples are equal (true), if they have the same length and all the data items on each index position are equal. If the operands have different types (integer and real), the integer values are first transformed into real numbers. Values of type string cannot be mixed up with numbers, i.e., string values are considered to be not equal to values of other types.

1st Operand Operation 2nd Operand Result

1 == 1.0 true
[] == [] true
'' == [] false
[1,'2'] == [1,2] false
[1,2,3] == [1,2] false
[4711,'Hugo'] == [4711,'Hugo'] true
'Hugo' == 'hugo' false
2 > 1 true
2 > 1.0 true
[5,4,1] > [5,4] true
[2,1] > [2,0] true
true > false true
'Hugo' < 'hugo' true

Table 8.16: Examples for the comparison of tuples.

The four comparison operations compute the lexicographic order of tuples. On equal index positions the types must be identical, however, values of type integer, real, and boolean are adapted automatically. The lexicographic order applies to strings, and the boolean false is considered to be smaller than the boolean true (false < true). In the program compare.hdev you can find examples for the comparison operations.