Pascal - operators

Operators perform an operation between the operands, this operation can be mathematical, logical, or bitwise.

Arithmetic operators

Are used to perform mathematical operations. the following are basic operations between the arithmetic operators:

Pascal

8 + 12        { 20}
100 - 2        { 98}
5 * 5          { 25}
50 / i         { 2.5}
70 div 8       { 8}
70 mod 8         { 6}

Logical

Three or four logical operations are available, exactly how much it depends on the particular programming language that we use. with these operations, we can solve any logical task or condition. these logical conditions are for example connections of comparing values according to certain rules, testing values. logical operations are mainly used in the execution of conditional statements.

Pascal

a and b
a or true
not a

Bitwise

We have more of the bitwise operators, using the bitwise operator we can set or determine the specific bit in whole numbers.

Pascal

2 shl 2      {}
2 shr 2      {}
$ff and $05 { 0x05}
$01 or $02 { 0x03}
not 2         {}
$1A xor $1A {}

Relational

The main use of the relational operators is in control of conditional statements. thanks to these, we can decide which direction to continue the conditional statements, or for example, how many iterations of the cycle need to perform.

Pascal

5 < 3        {   true}
x > 3.14     {   }
y <= x       {   ...}
$ff >= y    {   ...}
x = 6       {}
y <> 25      {}

Assignment


Examples - Pascal

Pascal

Other pieces of example codes:
if y<5 then
   y := y/ 3.14;    
not 2
x := 1 or 2;
if i - 10 >0 then i := i-5;
y <> 25
(3 + i)
Languages: en hu cz sk