The expression block returns result of expression. In the following examples, the number of decimal places is 2.
'$Math.cast($Enums.CastDataType.SINT, EXPRESSION)'
SINT |
Returns the value rounded to a 8 bit signed integer. |
USINT |
Returns the value rounded to a 8 bit unsigned integer. |
BYTE |
Returns the value rounded to a 8 bit unsigned integer. |
INT |
Returns the value rounded to a 16 bit signed integer. |
UINT |
Returns the value rounded to a 16 bit unsigned integer. |
WORD |
Returns the value rounded to a 16 bit unsigned integer. |
DINT |
Returns the value rounded to a 32 bit signed integer. |
(Example 1)
Round down to the closest integer: If Var1 is 1.9, the output is 1.
'$Math.cast($Enums.CastDataType.WORD, Var1)'
(Example 2)
If the variable value exceeds the range of the specified data type, the portion of the exceeded value loops between the minimum and maximum limits: If Var1 is 200, the output is -56.
'Math.cast($Enums.CastDataType.SINT, Var1)'
Returns the absolute value of the parameter.
parameter data type: integer, long, float, double.
Return value data type: Same as the set parameter data type.
'$Math.abs(EXPRESSION)'
(Example)
When Var1 is -3, output is 3.
'$Math.abs(Var1)'
Returns the arc cosine value (radians) of the parameter (ratio of 2 sides).
Parameter data type: double
Return value data type: double
'$Math.acos(EXPRESSION)'
(Example)
When Var1 is 1, output is 0.
'$Math.acos(Var1)'
Returns the arc sine value (radians) of the parameter (ratio of 2 sides).
Parameter data type: double
Return value data type: double
'$Math.asin(EXPRESSION)'
(Example)
When Var1 is 1, output is 1.57.
'$Math.asin(Var1)'
Return the arc tangent value (radians) of the parameter (ratio of 2 sides).
Parameter data type: double
Return value data type: double
'$Math.atan(EXPRESSION)'
(Example)
When Var1 is 1, output is 0.79.
'$Math.atan(Var1)'
Returns the arc tangent value (radians) of the parameters (base "b" and height "a").
Parameter data type: double
Return value data type: double
'$Math.atan2(EXPRESSION1, EXPRESSION2)'
(Example)
When Var1 is 2 and Var2 is 1, output is 1.11.
'$Math.atan2(Var1, Var2)'
Returns the smallest integer that is greater than the parameter.
Parameter data type: double
Return value data type: double
'$Math.ceil(EXPRESSION)'
(Example)
When Var1 is 1.2, output is 2.
'$Math.ceil(Var1)'
Return the cosine value (ratio of 2 sides) of the parameter (radians).
Parameter data type: double
Return value data type: double
'$Math.cos(EXPRESSION)'
(Example)
When Var1 is 1, output is 0.54.
'$Math.cos(Var1)'
Base value of natural logarithms. Double precision floating point number. 2.71828182845904523545f
'$Math.E()'
Use Math.E syntax.
Returns the exponential number e (i.e. 2.718...) to the power of the double value.
Parameter data type: double
Return value data type: double
'$Math.exp(EXPRESSION)'
(Example)
When Var1 is 1, the output is 2.718..(e1).
'$Math.exp(Var1)'
Returns the largest integer that is less than the parameter.
Parameter data type: double
Return value data type: double
'$Math.floor(EXPRESSION)'
(Example)
When Var1 is 1.5, output is 1.
'$Math.floor(Var1)'
Returns the remainder when parameter a is divided by parameter b.
Parameter data type: double
Return value data type: double
'$Math.IEEEremainder(EXPRESSION1, EXPRESSION2)'
(Example)
When Var1 is 11 and Var2 is 3, the output is -1.
'$Math.IEEEremainder(Var1, Var2)'
Returns the natural logarithm of the parameter.
Parameter data type: double
Return value data type: double
'$Math.log(EXPRESSION)'
(Example)
When Var1 is 2.72, the output is 1.
'$Math.log(Var1)'
Returns the larger of the 2 parameters. If both parameters are negative, the one with the smaller absolute value is returned.
Parameter data type: integer, long, float, double
Use the same data type for the parameter.
Return value data type: The same data type as the parameters.
'$Math.max(EXPRESSION1, EXPRESSION2)'
(Example)
When Var1 is 10 and Var2 is 2, the output is 10.
'$Math.max(Var1, Var2)'
Returns the smaller of the 2 parameters. If both parameters are negative, the one with the greater absolute value is returned.
Parameter data type: integer, long, float, double
Use the same data type for the parameter.
Return value data type: The same data type as the parameters.
'$Math.min(EXPRESSION1, EXPRESSION2)'
(Example)
When Var1 is 10 and Var2 is 2, the output is 2.
'$Math.min(Var1, Var2)'
The ratio of the circumference of a circle to its diameter.
3.14159265358979323846f
'$Math.PI()'
Use Math.PI syntax.
Returns ab.
Parameter data type: double
Return value data type: double
'$Math.pow(EXPRESSION1, EXPRESSION2)'
(Example)
When Var1 is 2 and Var2 is 3, the output is 8.
'$Math.pow(Var1, Var2)'
Returns a random number between 0.0 and 1.0.
Return value data type: double
'$Math.Random()'
The output of this function is a floating point number between 0 and 1.
Returns the closest integer to the parameter.
Parameter data type: double
Return value data type: double
'$Math.rint(EXPRESSION)'
The data types of the values used for parameters and return values are different for rint and round. Use each in accordance with the data type of the value in the expression.
(Example)
When Var1 is 1.4, the output is 1. And when Var1 is 1.5, the output is 2.
'$Math.rint(Var1)'
Returns the closest long for a double parameter, and the closest integer for a float parameter.
Parameter data type: double
Return value data type: long
or
Parameter data type: float
Return value data type: integer
'$Math.round(EXPRESSION)'
The data types of the values used for parameters and return values are different for rint and round. Use each in accordance with the data type of the value in the expression.
(Example)
When Var1 is 1.4, the output is 1. And when Var1 is 1.5, the output is 2.
'$Math.round(Var1)'
Return the sine value (ratio of 2 sides) of the parameter (radians).
Parameter data type: double
Return value data type: double
'$Math.sin(EXPRESSION)'
(Example)
When Var1 is 1, output is 0.84.
'$Math.sin(Var1)'
Returns the square root of the parameter.
Parameter data type: double
Return value data type: double
'$Math.sqrt(EXPRESSION)'
(Example)
When Var1 is 9, the output is 3.
'$Math.sqrt(Var1)'
Returns the tangent value (ratio of 2 sides) of the parameter (radians).
Parameter data type: double
Return value data type: double
'$Math.tan(EXPRESSION)'
(Example)
When Var1 is 1, output is 1.56.
'$Math.tan(Var1)'