Minus
│
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
The symbol -
(pronounced “minus”) is used to
- indicate the negative sign of a number
- subtract two numbers (using infix notation)
- form the difference of two sets.
program minusDemo(input, output, stderr);
var
x: longint;
g: longint;
m: set of (foo, bar);
begin
// unary operator: negative sign
x := -42; // x becomes negative 42
// binary operator: difference of numbers
g := 144 - 169; // g becomes negative 25
// binary operator: difference of sets
m := [foo, bar] - [bar]; // m becomes {foo}
end.
Beware:
The result's target of subtractions should be a signed integer.
If it's not, with {$rangechecks}}
enabled, it will cause an Run-time error.
Otherwise an arithmetically wrong result is produced.
program faultySubtraction(input, output, stderr);
var
x, y: longword;
begin
y := 1;
{$push}
{$rangechecks off} // otherwise the next expression
x := 0 - y; // yields RTE 201
{$pop}
writeLn(x);
end.
This program prints 4294967295
, which equals to high(longword)
because of the (unsigned) integer overflow.
single characters |
|
character pairs |
|