143
Structured Text (ST Language) Specifications Appendix B
Numerical Functions
The following numerical functions can be used in structured text.
Note The data type returned for numerical functions is the same as that used in the argument. Therefore, vari-
ables substituted for function return values must be the same data type as the argument.
Arithmetic Functions
The following general exponential function can be used in structured text.
Note The data type returned for the general exponential function is the same as that used in the argument.
Therefore, variables substituted for function return values must be the same data type as the argument.
Numerical
functions
Argument data type Return value
data type
Contents Example
ABS (argument) INT, DINT, LINT,
UINT, UDINT, ULINT,
REAL, LREAL
INT, DINT, LINT,
UINT, UDINT,
ULINT, REAL,
LREAL
Absolute value [argument] a: = ABS (b)
(*absolute value of variable b
stored in variable a*)
SQRT (argument) REAL, LREAL REAL, LREAL Square root:
√ argument
a: = SQRT (b)
(*square root of variable b
stored in variable a*)
LN (argument) REAL, LREAL REAL, LREAL Natural logarithm: LOG
e
argument
a: = LN (b)
(*natural logarithm of vari-
able b stored in variable a*)
LOG (argument) REAL, LREAL REAL, LREAL Common logarithm:
LOG
10
argument
a: = LOG (b)
(*common logarithm of vari-
able b stored in variable a*)
EXP (argument) REAL, LREAL REAL, LREAL
Natural exponential: e
argu-
ment
a: = EXP (b)
(*natural exponential of vari-
able b stored in variable a*)
SIN (argument) REAL, LREAL REAL, LREAL Sine: SIN argument a: = SIN (b)
(*sine of variable b stored in
variable a*)
COS (argument) REAL, LREAL REAL, LREAL Cosine: COS argument a: = COS (b)
(*cosine of variable b stored
in variable a*)
TAN (argument) REAL, LREAL REAL, LREAL Tangent: TAN argument a: = TAN (b)
(*tangent of variable b stored
in variable a*)
ASIN (argument) REAL, LREAL REAL, LREAL
Arc sine: SIN
−
1
argument
a: = ASIN (b)
(*arc sine of variable b
stored in variable a*)
ACOS (argument) REAL, LREAL REAL, LREAL
Arc cosine: COS
−
1
argu-
ment
a: = ACOS (b)
(*arc cosine of variable b
stored in variable a*)
ATAN (argument) REAL, LREAL REAL, LREAL
Arc tangent: TAN
−
1
argu-
ment
a: = ATAN (b)
(*arc tangent of variable b
stored in variable a*)
Exponential
function
Argument data type Return value
data type
Contents Example
EXPT (base, expo-
nent)
Base: REAL, LREAL
Exponent: INT, DINT,
LINT, UINT, UDINT,
ULINT
REAL, LREAL
Exponential: Base
exponent
a: = EXPT (b, c)
(*Exponential with variable b
as the base and variable c as
the exponent is stored in
variable a*)