Table of Contents

5.6.9.5 Relational Operators

Note

This section describes the implementation of MS-VBAL §5.6.9.5 Relational Operators.

Runtime Semantics

Relational operators are simple data operators: they validate their operands through OperatorRuntimeSemantics.LetCoerceNonNullOperand (RD-VBAL §5.6.9.2 Simple Data Operators).

Relational operators compare in the effective type, and yield a VBBooleanValue.

Effective type Compared in
Integral The effective type's own representation: for example Long as a 32-bit int, and LongLong as a 64-bit long.
Boolean A 64-bit integer (long).
Fixed-point (Currency, Decimal) decimal
Condition Run-time error
An operand is NaN. 6 — Overflow

Run-time error 6 is VBRuntimeErrorId.Overflow.

👉 The range checks of a For loop use the relational operators RDCore.Runtime.Semantics.Operators.Relational.BinaryGtRelationalOperatorRuntimeSemantics and BinaryLtRelationalOperatorRuntimeSemantics, not a raw numeric comparison (RD-VBAL §5.4.2.3 For Statement).

Variant String/Numeric comparison

RD-VBA implements the Variant String/Numeric comparison exception of MS-VBAL §5.6.9.5 as run-time behaviour.

The exception applies when both relational operands are Variant, one originally holding a String value and the other a numeric value:

  • The numeric operand is always considered less than the String operand, regardless of their actual values.
  • RD-VBA never attempts to coerce the String operand to a number. Depending on its content, that coercion would fail, or succeed incorrectly.

BinaryRelationalOperatorRuntimeSemantics handles the exception as a short-circuit:

  1. It detects the Variant String/Numeric case before normal effective-type determination and coercion run.
  2. It reduces the case to a synthetic Integer rank for each operand (table below).
  3. The relational operator's ordinary Integer evaluation branch compares the synthetic ranks.
Operand Synthetic Integer rank
The numeric-holding Variant 0
The String-holding Variant 1

The short-circuit runs before normal coercion because normal coercion would otherwise try, and fail, to coerce the String to a number. Because the case is reduced to synthetic ranks, the Variant String/Numeric case needs no separate evaluation path.

5.6.9.5.1 = Operator

This section corresponds to MS-VBAL §5.6.9.5.1 = Operator.

Note

Reserved. This section has no content yet.

5.6.9.5.2 <> Operator

This section corresponds to MS-VBAL §5.6.9.5.2 <> Operator.

Note

Reserved. This section has no content yet.

5.6.9.5.3 < Operator

This section corresponds to MS-VBAL §5.6.9.5.3 < Operator.

Note

Reserved. This section has no content yet.

5.6.9.5.4 > Operator

This section corresponds to MS-VBAL §5.6.9.5.4 > Operator.

Note

Reserved. This section has no content yet.

5.6.9.5.5 <= Operator

This section corresponds to MS-VBAL §5.6.9.5.5 <= Operator.

Note

Reserved. This section has no content yet.

5.6.9.5.6 >= Operator

This section corresponds to MS-VBAL §5.6.9.5.6 >= Operator.

Note

Reserved. This section has no content yet.


⏮️ RD-VBAL §5.6.9.4 & Operator | ⏭️ RD-VBAL §5.6.9.6 Like Operator