pow()

The mathLib.pow() system function returns a number raised to the power of a second number.

EGL maintains this function for compatibility with earlier versions. For new code, use the exponent operator (**, which translates as "to the power of"). See Operators and precedence. There are two minor differences between the function and the operator:
  • If you have set the v60ExceptionCompatibility program property to YES, EGL sets SysVar.errorCode to "00000000" upon successful completion of the mathLib.pow() function. The ** operator does not change SysVar.errorCode.
  • If the result is not a valid number (infinity, for example), the ** operator treats the situation as a numeric overflow; if you called the mathLib.pow() function, the result depends on the v60ExceptionCompatibility property, as described in EGL library mathLib.

Syntax

  mathLib.pow(
    numericVariable1 FLOAT in,
    numericField2 FLOAT in)
  returns (result FLOAT)
numericVariable1
Input can be any variable or expression that is assignment compatible with the FLOAT type.
numericVariable2
Input can be any variable or expression that is assignment compatible with the FLOAT type.
result
The value of numericVariable1 to the power of numericVariable2 is returned as a FLOAT.

Example

  x INT = 2;
  y INT = 3;
  result = mathLib.pow(x,y);  // result = 8
  result = x**y;   // result = 8

Error conditions

EGL finds an error condition if, given pow(x,y), x is negative and y is not a whole number, or x is 0 and y is negative. The effect of the error condition depends on the value of the v60ExceptionCompatibility property; for more information, see EGL library mathLib.