HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to DelphiVariablesData Types & ConversionOperatorsStringsConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔄 Data Types & Conversion
✍️ String
🔁 Condition & Loop
🧩 Function & Procedure
Delphi›Operators

Operators

Math (+ - * div mod), comparison (= <>) and logic (and or not).

Simple enough for a 5-year-old to understand

div and mod

Integer division uses div, remainder uses mod. / gives a decimal result.

Example code
1
program H;
2
{$MODE DELPHI}
3
begin
4
writeln(7 div 2);
Integer division: 3
CodeInteger division: 3
5
writeln(7 mod 2);
Remainder: 1
CodeRemainder: 1
6
end.
Code
💡 Hint: Integer division uses div, remainder uses mod. Equality is =, inequality is <>.

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print the remainder (mod) of 23 divided by 4.

🎯 Expected output: 3

Loading editor…

About this topic

Delphi's operators are inherited from Pascal: arithmetic operations, not equal written with angle brackets, logical operations expressed with words, and two separate division operators.

The most important detail is still the precedence rule. The precedence of logical operators is higher than comparison, so using parentheses in compound conditions is mandatory. Delphi is the same as Pascal in this regard.

Short-circuit evaluation is enabled by default in Delphi: when the result is determined in a compound condition, the remaining part is not evaluated. This makes it possible to write null object checks in a single line, but since it can be disabled via compiler settings, one must be careful when relying on it.

What you will learn

  • Arithmetic and division operators
  • Comparison operators
  • Logical operators and precedence
  • Short-circuit evaluation
  • Bitwise operations

Who is this for?

  • Those who encounter errors when writing conditions
  • Developers coming from the C family
  • Those surprised by the division result

When to use?

When combining object checks with field access in the same condition, you rely on short-circuit evaluation; you need to make sure the compiler setting is enabled.

Bitwise operators are used for flag and mask operations; since these are written with the same keywords, it is important not to confuse the context.

Common mistakes

Wrong

var
  a, b: Integer;
begin
  a := 5; b := 2;
  if a > 1 and b < 3 then
    writeln('ok');
end.

Since the precedence of the logical operator is higher than comparison, the expression tries to combine the two values in the middle bitwise and causes a compilation error. Every comparison must be enclosed in parentheses.

Correct

var
  a, b: Integer;
begin
  a := 5; b := 2;
  if (a > 1) and (b < 3) then
    writeln('ok');
end.

Wrong

var
  sonuc: Integer;
begin
  sonuc := 7 / 2;
  writeln(sonuc);
end.

The forward slash always produces a floating-point result; this value cannot be assigned to an integer variable and a compilation error occurs. You must use the operator written with letters for integer division.

Correct

var
  sonuc: Integer;
begin
  sonuc := 7 div 2;
  writeln(sonuc);
end.

Wrong

var
  liste: TStringList;
begin
  liste := nil;
  if (liste.Count > 0) and (liste <> nil) then
    writeln('full');
end.

The order of conditions is reversed: an access violation occurs because field access is performed on a null object. Short-circuit evaluation only works if the check is written first. The guard condition must always be at the very beginning.

Correct

var
  liste: TStringList;
begin
  liste := nil;
  if (liste <> nil) and (liste.Count > 0) then
    writeln('full');
end.

Frequently asked questions

How do I control short-circuit evaluation?

Project options include a complete logical evaluation setting; when turned off, short-circuiting is performed. You can also specify it at the file level by writing a directive in the code. It is safe to explicitly write this directive in critical places.

Is there an increment operator?

There is no operator, but increment and decrement procedures exist in the standard library. In most cases, writing explicit assignments is more readable and the compiler produces the same machine code.

How are string comparisons performed?

The equals operator compares content in strings, not references. If you want to ignore case sensitivity, you need to use the comparison functions in the standard library; it is important to choose the locale-sensitive version for Turkish characters.

Summary

The not equal operator is written with angle brackets.

The precedence of logical operators is higher than comparison.

Parentheses are mandatory in compound conditions.

The forward slash produces a floating-point result.

The guard condition is always written first.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code