Difference between revisions of "Plus"

From Free Pascal wiki
Jump to navigationJump to search
m
Line 9: Line 9:
 
* form a union of [[Set|sets]],
 
* form a union of [[Set|sets]],
 
* (FPC) concatenate two strings (or characters; except [[PChar|<syntaxhighlight lang="pascal" enclose="none">pchar</syntaxhighlight>]]).
 
* (FPC) concatenate two strings (or characters; except [[PChar|<syntaxhighlight lang="pascal" enclose="none">pchar</syntaxhighlight>]]).
 +
 +
In [[ASCII]], the character code decimal <syntaxhighlight lang="pascal" enclose="none">43</syntaxhighlight> (or [[Hexadecimal|hexadecimal]] <syntaxhighlight lang="pascal" enclose="none">2B</syntaxhighlight>) is defined to be <syntaxhighlight lang="pascal" enclose="none">+</syntaxhighlight> ( Plus sign  ).
  
 
<syntaxhighlight lang="pascal" line>
 
<syntaxhighlight lang="pascal" line>
Line 41: Line 43:
  
 
{{Symbols}}
 
{{Symbols}}
 
[[Category:Pascal]]
 
[[Category:Symbols]]
 
[[Category:Code]]
 

Revision as of 10:23, 17 April 2018

English (en) suomi (fi) français (fr) русский (ru)

+

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

  • explicitly indicate the positive sign of a number,
  • add two numbers resulting to a number,
  • form a union of sets,
  • (FPC) concatenate two strings (or characters; except pchar).

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

 1program plusDemo(input, output, stderr);
 2
 3var
 4	x: longint;
 5	g: set of (foo, bar);
 6	m: string;
 7begin
 8	// unary operator: positive sign
 9	x := +7;                    // x becomes positive 7
10	x := +$100;                 // x becomes 256
11	                            // (dollar sign denotes hexadecimal base)
12	
13	// addition
14	x := 7 + 7;                 // x becomes 14
15	x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
16	
17	// union of sets
18	g := [foo] + [bar];         // g becomes [foo, bar]
19	
20	// concatenation of strings and/or characters (FPC/Delphi extension)
21	m := 'Hello ' + 'world!';   // m becomes 'Hello world!'
22end.

see also


navigation bar: topic: Pascal symbols
single characters

+ (plus)  •  - (minus)  •  * (asterisk)  •  / (slash)
= (equal)  •  > (greater than)  •  < (less than)
. (period)  •  : (colon)  •  ; (semi colon)
^ (hat)  •  @ (at)
$ (dollar sign)  •  & (ampersand)  •  # (hash)
' (single quote)

character pairs

<> (not equal)  •  <= (less than or equal)  •  := (becomes)  •  >= (greater than or equal)

 •  >< (symmetric difference)  •  // (double slash)