Difference between revisions of "Minus"
(add content, remove Template:Stub) |
|||
Line 6: | Line 6: | ||
* indicate the negative sign of a number | * indicate the negative sign of a number | ||
* subtract two numbers (using infix notation) | * subtract two numbers (using infix notation) | ||
− | * form the difference of two sets. | + | * form the difference of two [[Set|sets]]. |
+ | |||
+ | In [[ASCII]], the character code decimal <syntaxhighlight lang="pascal" enclose="none">45</syntaxhighlight> | ||
+ | (or [[Hexadecimal|hexadecimal]] <syntaxhighlight lang="pascal" enclose="none">2D</syntaxhighlight>) is defined to be | ||
+ | <syntaxhighlight lang="pascal" enclose="none">-</syntaxhighlight> (Minus sign). | ||
+ | |||
+ | |||
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal"> | ||
Line 51: | Line 57: | ||
{{Symbols}} | {{Symbols}} | ||
− | |||
− | |||
− |
Revision as of 08:46, 19 April 2018
│
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.
In ASCII, the character code decimal 45
(or hexadecimal 2D
) is defined to be
-
(Minus sign).
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 |
|