Relational Operators

Relational operators are used to compare two operands. The operators =, <>, <=, and >= also apply to sets.

Relational Operators

Operator

Operation

Operand Types

Result Type

Example

=

equality

simple, class, class reference, interface, string, packed string

Boolean

I = Max

<>

inequality

simple, class, class reference, interface, string, packed string

Boolean

X <> Y

<

less-than

simple, string, packed string, PChar

Boolean

X < Y

>

greater-than

simple, string, packed string, PChar

Boolean

Len > 0

<=

less-than-or-equal-to

simple, string, packed string, PChar

Boolean

Cnt <= I

>=

greater-than-or-equal-tosimple, string, packed string, PChar

Boolean

I >= 1

For most simple types, comparison is straightforward. For example, I = j is True just in case I and J have the same value, and I <> j is True otherwise. The following rules apply to relational operators.

  • Operands must be of compatible types, except that a real and an integer can be compared.
  • Strings are compared according to the ordinal values that make up the characters that make up the string. Character types are treated as strings of length 1.
  • Two packed strings must have the same number of components to be compared. When a packed string with n components is compared to a string, the packed string is treated as a string of length n.
  • Use the operators <, >, <=, and >= to compare PChar (and PWideChar) operands only if the two pointers point within the same character array.
  • The operators = and <> can take operands of class and class-reference types. With operands of a class type, = and <> are evaluated according the rules that apply to pointers: c = d is True just in case c and d point to the same instance object, and c <> d is True otherwise. With operands of a class-reference type, c = d is True just in case c and d denote the same class, and c <> d is True otherwise. This does not compare the data stored in the classes. For more information about classes, see Classes and objects.
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment