Sign in Join
Wiki copytemporary

Plus: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Plus

OldNewLine
1+<div style="float:right; margin: 0 10px 10px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">
2+
3+\+
4+
5+</div>
6+
7+The symbol `+` (pronounced “plus”) is used to:
8+
9+- explicitly indicate the positive sign of a number,
10+- add two numbers resulting to a number,
11+- form a union of [[Set|sets]],
12+- (FPC) concatenate two strings (or characters; except [[PChar|pchar]]).
13+- if `{$modeSwitch arrayOperators+}` (default in [[Mode Delphi|{$mode Delphi}]]), concatenate arrays (since FPC 3.2.0)
14+- enable a feature in a `{$modeSwitch}`
15+
16+``` pascal
17+program plusDemo(input, output, stderr);
18+
19+var
20+ x: longint;
21+ g: set of (foo, bar);
22+ m: string;
23+begin
24+ // unary operator: positive sign
25+ x := +7; // x becomes positive 7
26+ x := +$100; // x becomes 256
27+ // (dollar sign denotes hexadecimal base)
28+
29+ // addition
30+ x := 7 + 7; // x becomes 14
31+ x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
32+
33+ // union of sets
34+ g := [foo] + [bar]; // g becomes [foo, bar]
35+
36+ // concatenation of strings and/or characters (FPC/Delphi extension)
37+ m := 'Hello ' + 'world!'; // m becomes 'Hello world!'
38+end.
39+```
40+
41+The plus sign is also a unary operator. One can write such stupid expressions as `++++++++++++++42` which will evaluate to positive 42.
42+
43+In [[ASCII]], the character code decimal `43` (or [[Hexadecimal|hexadecimal]] `2B`) is defined to be `+` (plus sign).
44+
45+## see also
46+
47+- [`system.add`](https://www.freepascal.org/docs-html/rtl/system/.op-add-variant-ariant-ariant.html)
48+- [`system.concat`](https://www.freepascal.org/docs-html/rtl/system/concat.html) returns concatenation of strings
49+- [`strings.strcat`](https://www.freepascal.org/docs-html/rtl/strings/strcat.html) returns concatenation of [[PChar|pchar]] strings
50+
51+---
52+*From the Free Pascal wiki, page "Plus", as it stood on 2019-10-16 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history