Sign in Join
Wiki copytemporary

Revision 1 of 3, by Kai Burghardt on 10-16-2019. The page as it is now.

Plus

<div style="float:right; margin: 0 10px 10px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">

+

</div>

The symbol + (pronounced “plus”) is used to:

pascal
program plusDemo(input, output, stderr);

var
    x: longint;
    g: set of (foo, bar);
    m: string;
begin
    // unary operator: positive sign
    x := +7;                    // x becomes positive 7
    x := +$100;                 // x becomes 256
                                // (dollar sign denotes hexadecimal base)
    
    // addition
    x := 7 + 7;                 // x becomes 14
    x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
    
    // union of sets
    g := [foo] + [bar];         // g becomes [foo, bar]
    
    // concatenation of strings and/or characters (FPC/Delphi extension)
    m := 'Hello ' + 'world!';   // m becomes 'Hello world!'
end.

The plus sign is also a unary operator. One can write such stupid expressions as ++++++++++++++42 which will evaluate to positive 42.

In ASCII, the character code decimal 43 (or hexadecimal 2B) is defined to be + (plus sign).

see also


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.