Operators: |

OR operator.

Syntax

integer‑operand|integer‑operand

rect‑operand|rect‑operand

Bitwise OR

In its first version, the | operator performs on the both operands a bitwise OR operation. 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 uint32 a = 0xFF003AC0;
var uint32 b = 0xAB15FF70;
var int32  c =  1369; // = 0x00000559
var int32  d = -1496; // = 0xFFFFFA28
var uint64 e = 0x1234AB15FF70;
var int64  f = -149613691251;  // = 0xFFFFFFDD2A543E8D

var uint32 result = a | b; // result = 0xFF15FFF0
var int32  result = c | d; // result = -135
var uint32 result = a | d; // result = 0xFFFFFAE8
var int64  result = a | f; // result = 0xFFFFFFDDFF543ECD
var uint64 result = d | e; // result = 0xFFFFFFFFFFFFFF78

Rectangle union

In its second version, the | operator determines the union of two rectangles. The result is a new rectangle representing an area where both the left and the right rect operands are completely included. If one of the rectangles is empty, the operator returns immediately the counterpart operand without performing any calculations. For example:

var rect a = <10,5,110,220>;
var rect b = <-10,-50,50,75>;
var rect c = <110,5,120,220>;
var rect d = <0,0,0,0>;

var rect result = a | b; // result = <-10,-50,110,220>
var rect result = b | a; // result = <-10,-50,110,220>
var rect result = a | c; // result = <10,5,120,220>
var rect result = a | d; // result = <10,5,110,220>