Skip to main content

varSmallInt

varSmallInt = 2

Example

function HasSigned16Storage(const Value: Variant): Boolean;
begin
Result := (VarType(Value) and varTypeMask) = varSmallInt;
end;

Usage

varSmallInt identifies a signed 16-bit Variant integer that Velox may select as the smallest type for a source value.

Additional Technical Info

varSmallInt is the base TVarType code $0002 for a signed 16-bit integer (-32,768..32,767).

With Delphi's default PackVarCreation=True, Variant construction can select a compact integer tag that reflects the source type/range. The same number can therefore be varShortInt, varSmallInt, varInteger or another compatible representation. Exact tag equality is not a complete numeric-family test.

VarAsType with varSmallInt narrows/converts the source. Validate range and integrality before doing so; invalid text, fractional values and numbers outside the 16-bit range can round, reject or raise a conversion/range/overflow exception.

Do not confuse the code with unsigned varWord. Values 32,768..65,535 fit Word but not SmallInt, while negative SmallInt values cannot be Word.

VarType only reads the raw tag. Mask away flags for a base comparison.

The example is source-reviewed only; no conversion was executed.

External references

Created 2026-07-15