Operator ‘EXPT’ΒΆ

This IEC operator raises a number to a higher power and returns the power of the base raised to the exponent: power = base exponent. The input values (parameters) are the base and the exponent. The power function is undefined if the base is zero and the exponent is negative. However, the behavior depends on the platform in this case.

Syntax:

EXPT(<base>,<exponent>)

Permitted data types for the input values: Numeric base data types (SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT, REAL, LREAL, BYTE, WORD, DWORD, and LWORD)

Permitted data types for the return value: Floating-point number types (REAL and LREAL)

Example

Power function with literals

Var1 := EXPT(7,2);

FBD:

Return value: Var1 = 49

Example

Power function with variables

PROGRAM PLC_PRG
VAR
        lrPow : LREAL;
        iBase : INT := 2;
        iExponent : INT := 7;
END_VAR

lrPow := EXPT(iBase, iExponent);

Return value: lrPow = 128