4.9 Comparison Operators

The comparison operators can only be used on data of the same type. Table 4.6 shows the list of operators for numeric format data. Similarly, the operators shown in the table below can be applied to character format, date format, time format data.

Table 4.6: Summary of comparison operators

Details of comparison

Format

Example

Equal

$num_1==num_2$

1.5==1.5(0b1), "abc"=="abcd" (0b0)

Not equal

$num_1!=num_2$

1.5!=1.5(0b0), "abc"=="abcd" (0b1)

Greater than

$num_1>num_2$

10>5(0b1), "abc">"abcd" (0b0)

Less than

$num_1<num_2$

10<5(0b0), "abc"<"abcd" (0b1)

Above

$num_1>=num_2$

10>=10(0b1), "a">"" (0b1)

Below

$num_1<=num_2$

8<=9(0b1), "a"<="a" (0b1)


The results of the examples are shown in parentheses (the content is shown using constant numbers).