Operators: -

Minus operator.

Syntax

Unary form:

-integer‑operandor-float‑operandor-point‑operand

Binary form:

integer‑operand-integer‑operand

float‑operand-float‑operand

point‑operand-point‑operand

rect‑operand-point‑operand

color‑operand-color‑operand

char‑operand-char‑operand

styles‑operand-styles‑operand

user‑defined‑set‑operand-user‑defined‑set‑operand

Unary negative prefix

In its first, unary version the - operator expects one signed integer, unsigned integer, floating-point or point operand and results in the value of this operand with its sign inverted. Precisely, an operand with a positive value will become negative and a negative operand will become positive.

Applied on a signed or unsigned integer operand, the operation always results in an int32 value. Applied on a floating-point operand, the operation always results in a float value. Finally, when applied on a point operand, the operation results in a point value. Please note, performing the operation on a point operand, negates the x and y point elements individually. For example:

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

Integer subtraction

In its second version, the - operator calculates an arithmetic difference between the left and the right operand. If used with two signed integer operands, the resulting data type is always int32. In all other cases, the operation results in the unsigned uint32 value. For example:

var int32 a = 1369; var int32 b = -1496; var uint32 c = 1369; var uint32 d = 1251; var int32 result = a - b; // result = 2865 var uint32 result = c - d; // result = 118 var uint32 result = b - d; // result = 0xFFFFF545

Floating point subtraction

In its third version, the - operator calculates an arithmetic difference between the left and the right floating-point operand. The resulting data type of the operation is always a float. For example:

var float a = 1369.1251; var float b = -1496.158; var float result = a - b; // result = 2865.283

Point subtraction

In its fourth version, the - operator calculates an arithmetic difference between the left and the right point operand. The operation is performed individually for the x and y point elements. The subtraction of two point operands can be considered as a translation of the point in the left operand by a negative 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 = <50,130>

Rectangle negative displacement

In its fifth version, the - operator translates the left rectangle operand by an offset specified in the right point operand. During the operation, the x and y point elements are subtracted from 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 = <50,130,60,150> var rect result = b - a; // This operand combination is not allowed. Chora error

Color subtraction with saturation

In its sixth version, the - operator calculates an arithmetic difference between the left and the right color operand. The operation is performed individually for every red, green, blue and alpha color components by respecting the lower limit of the value range 0 .. 255. The resulting data type of the operation is always a color. For example:

var color a = #10C050FF; var color b = #225F2200; var color result = a - b; // result = #00612EFF

Char subtraction

In its seventh version, the - operator calculates an arithmetic difference between the codes of the left and the right character operand. Please note, in Chora all characters are handled as 16-bit UNICODE entities - they are represented as 16-bit UNICODE numbers. The resulting data type of the operation is always a int32. For example:

var char a = 'D'; var char b = 'A'; var int32 result = a - b; // result = 3

Styles difference

In its eighth version, the - operator determines the difference between the left and the right styles operand. 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 available in the left but not in the right operand. 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 ] var styles result = b - c; // result = [ Style3, Style16 ]

Set difference

In its ninth version, the - operator determines the difference between the left and the right user-defined set operand. 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 available in the left but not in 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, ResizeHorz ]; var Core::Layout result = a - b; // result = Core::Layout[ AlignToTop ] var Core::Layout result = b - c; // result = Core::Layout[]