Sign in Join
Wiki copytemporary

Plus: what changed

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

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-
31\+
4-
5-</div>
62
73The symbol `+` (pronounced “plus”) is used to:
84
95- explicitly indicate the positive sign of a number,
106- add two numbers resulting to a number,
117- form a union of [[Set|sets]],
128- (FPC) concatenate two strings (or characters; except [[PChar|pchar]]).
139- if `{$modeSwitch arrayOperators+}` (default in [[Mode Delphi|{$mode Delphi}]]), concatenate arrays (since FPC 3.2.0)
1410- enable a feature in a `{$modeSwitch}`
1511
1612``` pascal
1713program plusDemo(input, output, stderr);
1814
1915var
2016 x: longint;
2117 g: set of (foo, bar);
2218 m: string;
2319begin
2420 // unary operator: positive sign
2521 x := +7; // x becomes positive 7
2622 x := +$100; // x becomes 256
2723 // (dollar sign denotes hexadecimal base)
2824
2925 // addition
3026 x := 7 + 7; // x becomes 14
3127 x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
3228
3329 // union of sets
3430 g := [foo] + [bar]; // g becomes [foo, bar]
3531
3632 // concatenation of strings and/or characters (FPC/Delphi extension)
3733 m := 'Hello ' + 'world!'; // m becomes 'Hello world!'
3834end.
3935```
4036
4137The plus sign is also a unary operator. One can write such stupid expressions as `++++++++++++++42` which will evaluate to positive 42.
4238
4339In [[ASCII]], the character code decimal `43` (or [[Hexadecimal|hexadecimal]] `2B`) is defined to be `+` (plus sign).
4440
4541## see also
4642
4743- [`system.add`](https://www.freepascal.org/docs-html/rtl/system/.op-add-variant-ariant-ariant.html)
4844- [`system.concat`](https://www.freepascal.org/docs-html/rtl/system/concat.html) returns concatenation of strings
4945- [`strings.strcat`](https://www.freepascal.org/docs-html/rtl/strings/strcat.html) returns concatenation of [[PChar|pchar]] strings
5046
5147---
5248*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