Skip to main content

LessThan

LessThan = -1

Example

procedure ScriptEvent(var Value: variant);
var
Relationship: Integer;
begin
Relationship := CompareValue(9.5, 10.0);

if Relationship = LessThan then
Value := 'Below target';
end;

Usage

LessThan identifies the negative ordering result returned when a Velox numeric comparison places the left value below the right value.

Meaning of the result

For ordinary finite inputs, a result of LessThan means the left operand is below the right operand after applying the comparison's equality tolerance. It does not necessarily mean the raw Pascal expression A < B is sufficient: values within the inclusive tolerance band return Same.

  • CompareValue omits epsilon, so Velox calculates a magnitude- and platform-dependent default tolerance.
  • CompareValueEpsilon uses the explicit absolute tolerance supplied by the script; zero still selects Velox's calculated default.

Additional Technical Info

LessThan is the LongInt result code for the lower branch of Velox's three-way numeric comparison. The example receives -1 from CompareValue and sets Value to Below target. It is source-reviewed and is not executed by the documentation workflow.

Registration and implementation

vxCommonNumber declares the value as -1. The PascalScript compile-time import registers it as a LongInt constant with enumeration classification; it has no mutable storage and needs no runtime function registration.

Velox's CompareValue and CompareValueEpsilon functions call Delphi's System.Math.CompareValue. Delphi returns a TValueRelationship in the range -1..1; LessThan deliberately mirrors its LessThanValue value. LessThanValue and LessThanValueEpsilon compare the Delphi result with this exact constant.

Edge cases and quirks

  • The constant represents a result; it does not perform a comparison by itself.
  • A difference exactly equal to a valid positive epsilon is classified as Same, not LessThan.
  • With a NaN operand, Delphi's same test and < branch do not produce LessThan; the current implementation falls through to the greater result. Validate finite values when a total mathematical ordering is required.
  • Default-tolerance results can differ between Win32 and Win64 because Delphi's Extended precision and resolution differ.
  • Do not use LessThan as a generic negative status, sort callback result or error code unless that consumer explicitly accepts the Velox comparison contract.

Type and conversion boundaries

The imported type is LongInt, even though the value corresponds to Delphi's bounded TValueRelationship. Store it in Integer, LongInt or a carefully validated Variant; an arbitrary negative value is not automatically LessThan.

Side effects

None. The constant is resolved at script compile time.

Errors

Referencing the constant does not raise. The comparison that produces it can fail earlier if a dynamic input cannot convert to the required numeric type.

Performance and concurrency

Reading the constant is allocation-free and has no shared mutable state.

Related entries

External references

Created 2026-07-15