Create expressions using data, operators, mathematical functions, and data type conversions.
Use these operators to perform simple arithmetic operations. Use them to calculate numerical values, such as "TankLevel + 60".
Operator |
Expression |
Description |
[+] |
X + Y |
Add |
[-] |
X - Y |
Subtract |
[*] |
X * Y |
Multiply |
[/] |
X / Y |
Divide |
[%] |
X % Y |
Remainder of division |
[()] |
(X + Y)*10 |
|
Use the Add operator (+) to perform string concatenation. In other words, you can concatenate strings with the Add symbol, "Hello " + " " + "Billy" creates the string "Hello Billy".
Operator |
Expression |
Description |
[>>] |
X >> Y |
Right shift. Shifts the bits in X, to the right, by the Y number of bit positions. Preserves the sign. |
[<<] |
X << Y |
Left shift. Shifts the bits in X, to the left, by the Y number of bit positions. Preserves the sign. |
[>>>] |
X >>> Y |
Zero fill, right shift. Shifts the bits in X, to the right, by the Y number of bit positions, and fills in shifted bits on the left with 0s, thereby not preserving the sign. |
[&] |
X & Y |
Returns the result of the AND operation at the bit level. If X = 0110; Y= 1100 then the result is 0100 |
[|] |
X | Y |
Returns the result of the OR operation at the bit level. If X = 0110; Y= 1100 then the result is 1110 |
[^] |
X ^ Y |
Returns the result of the XOR operation at the bit level. If X = 0110; Y= 1100 then the result is 1010 |
[~] |
~X |
Flips the bits in the value X. If X = 0110; then the result is 1001 |
[!] |
!X |
Returns true when X is not equal. |
These operators compare two values. The expression returns true when the defined comparison is true. The expression returns false when the defined comparison is false. Use them to compare numerical values, such as "TankLevel > 30".
When one of the following occurs in a value, the result is undefined:
Divide by zero.
Operator |
Expression |
Description |
||||||||||||||||||
[&&] |
X && Y |
Logical AND.
|
||||||||||||||||||
[||] |
X || Y |
Logical OR.
|
||||||||||||||||||
[==] |
X == Y |
Returns true when X is equal to Y. |
||||||||||||||||||
[!=] |
X != Y |
Returns true when X is not equal to Y. |
||||||||||||||||||
[<=] |
X <= Y |
Returns true when X is less than or equal to Y. This operator cannot be used for BOOL variable, STRING variable, and WSTRING variable. |
||||||||||||||||||
[>=] |
X >= Y |
Returns true when X is greater than or equal to Y. This operator cannot be used for BOOL variable, STRING variable, and WSTRING variable. |
||||||||||||||||||
[<] |
X < Y |
Returns true when X is less than Y. This operator cannot be used for BOOL variable, STRING variable, and WSTRING variable. |
||||||||||||||||||
[>] |
X > Y |
Returns true when X is greater than Y. This operator cannot be used for BOOL variable, STRING variable, and WSTRING variable. |
Method |
Description |
abs(a) |
Returns the absolute value. parameter: integer, return: integer -or- |
acos(double a) |
Returns the arc cosine. parameter: double, return: double |
asin(double a) |
Returns the arc sine. parameter: double, return: double |
atan(double a) |
Returns the arc tangent. parameter: double, return: double |
atan2(double a, double b) |
Returns the arc tangent of a/b. parameter a: double, parameter b: double, return: double |
ceil(double a) |
Returns the smallest integer that is greater than the parameter. parameter: double, return: double |
cos(double a) |
Returns the cosine. parameter: double, return: double |
E |
Base value of natural logarithms. Double precision floating point number. 2.71828182845904523545f Use Math.E syntax. |
exp(double a) |
Returns the exponential number e (i.e. 2.718...) raised to the power of a double value. parameter: double, return: double |
floor(double a) |
Returns the largest integer that is less than the parameter. parameter: double, return: double |
IEEEremainder(double a, double b) |
Returns the remainder when parameter a is divided by parameter b. parameter a: double, parameter b: double, return: double |
log(double a) |
Returns the natural logarithm of the parameter. parameter: double, return: double |
max(a,b) |
Returns the larger of the 2 parameters. parameter a: integer, parameter b: integer, return: integer
-or- |
min(a,b) |
Returns the smaller of the 2 parameters. parameter a: integer, parameter b: integer, return: integer
-or- |
PI |
The ratio of the circumference of a circle to its diameter. 3.14159265358979323846f Use Math.PI syntax. |
pow(double a, double b) |
Returns ab. parameter a: double, parameter b: double, return: double |
random() |
Returns a random number between 0.0 and 1.0. parameter: none, return: double The output of this function is a floating point number between 0 and 1. |
rint(double a) |
Returns the closest integer to the parameter. parameter: double, return: double |
round(a) |
Returns the closest long for a double parameter, and the closest integer for a float parameter. parameter: double, return: long -or- |
sin(double a) |
Returns the sine of the parameter. parameter: double, return: double |
sqrt(double a) |
Return the square root of the parameter. parameter: double, return: double |
tan(double a) |
Returns the tangent of the parameter. parameter: double, return: double |
Use type conversion to convert data type. The following is an example of a valid expression, where the LWORD variable is converted to SINT variable:
Type |
Description |
---|---|
(sint) |
Returns the value rounded into 8 bit signed integer. |
(usint) |
Returns the value rounded into 8 bit unsigned integer. |
(byte) |
Returns the value rounded into 8 bit unsigned integer. |
(int) |
Returns the value rounded into 16 bit signed integer. |
(uint) |
Returns the value rounded into 16 bit unsigned integer. |
(word) |
Returns the value rounded into 16 bit unsigned integer. |
(dint) |
Returns the value rounded into 32 bit signed integer. |