Operators: +

Plus operator.

Syntax

Unary form:

+integer‑operandor+float‑operandor+point‑operand

Binary form:

integer‑operand+integer‑operand

float‑operand+float‑operand

float‑operand+integer‑operandorinteger‑operand+float‑operand

point‑operand+point‑operand

rect‑operand+point‑operandorpoint‑operand+rect‑operand

color‑operand+color‑operand

string‑operand+string‑operand

string‑operand+char‑operandorchar‑operand+string‑operand

char‑operand+integer‑operandorinteger‑operand+char‑operand

styles‑operand+styles‑operand

user‑defined‑set‑operand+user‑defined‑set‑operand

Unary positive prefix

The its first, unary version the + operator expects one signed integer, unsigned integer, floating-point or point operand and results in the unchanged, original value of this operand. The resulting data type of the operation corresponds to the original type of the operand. For example:

var float a = -1369.1251; var uint32 b = 4032; var point c = <100,-200>; var float result = +a; // result = -1369.1251 var uint32 result = +b; // result = 4032 var point result = +c; // result = <100,-200>

Integer addition

In its second version, the + operator calculates an arithmetic sum of the both operands. If used in combination with 8-, 16- or 32-bit signed integer operands, the data type resulting from the operation is consequently int32. When mixing signed and unsigned integer operands, the operation results in the unsigned uint32 value. In the case, one of the operands is 64-bit large, the resulting data type is int64 or uint64 according to whether the 64-bit operand is signed or unsigned. For example:

var int32 a = 1369; var int32 b = -1496; var uint32 c = 1369; var uint32 d = 1251; var uint64 e = 897546641189; var int64 f = -149613691251; var int32 result = a + b; // result = -127 var uint32 result = c + d; // result = 2620 var uint32 result = b + d; // result = 0xFFFFFF0B var int64 result = f + c; // result = -149613689882 var uint64 result = e + a; // result = 897546642558

Floating point addition

In its third version, the + operator calculates an arithmetic sum of the both floating-point operands. If used in combination with a signed or unsigned integer operand, the integer operand is automatically converted to float before performing the addition. The resulting data type of the operation is always a float. For example:

var float a = 1369.1251; var float b = -1496.158; var int32 c = 260; var float result = a + b; // result = -127.03283691 var float result = b + c; // result = -1236.157958

Point addition

In its fourth version, the + operator calculates an arithmetic sum of the both point operands. The operation is performed individually for the x and y point elements. The addition of two point operands can be considered as a translation of the point in the left operand by an offset specified in the right operand. The resulting data type of the operation is always a point. For example:

var point a = <100,200>; var point b = <50,70>; var point result = a + b; // result = <150,270>

Rectangle positive displacement

In its fifth version, the + operator translates a rectangle operand by an offset specified in the point operand. During the operation, the x and y point elements are added to the corresponding coordinates of the rectangle's top-left and bottom-right corners. The resulting data type of the operation is always a rect. For example:

var rect a = <100,200,110,220>; var point b = <50,70>; var rect result = a + b; // result = <150,270,160,290> var rect result = b + a; // result = <150,270,160,290>

Color addition with saturation

In its sixth version, the + operator calculates an arithmetic sum of the both color operands. The operation is performed individually for every red, green, blue and alpha color components by respecting the upper limit of the value range 0 .. 255. The resulting data type of the operation is always a color. For example:

var color a = #10C050F0; var color b = #225F22E0; var color result = a + b; // result = #32FF72FF

String concatenation

In its seventh version, the + operator creates a copy of the left string operand followed by the copy of the string in the right operand. This results in the both strings being concatenated. The resulting data type of the operation is always a string. Similarly, in the eighth version a string and a char operand ca be concatenated to a new string. For example:

var string a = "Hello"; var string b = "World"; var char c = '!'; var string result = a + " " + b + c; // result = "Hello World!"

Char integer addition

In its ninth version, the + operator performs an arithmetic addition between a signed or unsigned integer value and the character code stored in a char operand. The result of the operation is again char value. In this way, it is possible to calculate new character codes from given character code and an offset. For example:

var char c = 'A'; var char result = c + 32; // result = 'a'

Styles union

In its tenth version, the + operator combines the both styles operands to a new styles value. Please note, styles operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the + operation results in a new styles value including all elements from the left and the right operands. The resulting data type of the operation is always styles. For example:

var styles a = [ Style1, Style3, Style16 ]; var styles b = [ Style3, Style16 ]; var styles c = [ Style1, Style8 ]; var styles result = a + b; // result = [ Style1, Style3, Style16 ] var styles result = b + c; // result = [ Style1, Style3, Style8, Style16 ]

Set union

In its eleventh version, the + operator combines the both user-defined set operands to a new set value. Please note, set operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the + operation results in a new set value including all elements from the left and the right operand. The resulting data type of the operation corresponds to the data type of the operands. For example:

var Core::Layout a = Core::Layout[ AlignToTop, ResizeHorz ]; var Core::Layout b = Core::Layout[ ResizeHorz ]; var Core::Layout c = Core::Layout[ AlignToTop, ResizeVert ]; var Core::Layout result = a + b; // result = Core::Layout[ AlignToTop, ResizeHorz ] var Core::Layout result = b + c; // result = Core::Layout[ ResizeHorz, AlignToTop, ResizeVert ]