Developer Documentation Library > Scripting > UNICOM Intelligence Function Library > Mathematical functions > Exp
 
Exp
Returns e (the base of natural logarithms) raised to a power.
Syntax
Exp(Val)
Parameters
Val
Type: Double
A numeric value.
(return)
Type: Double
e to the power of Val.
Remarks
The return value is e (the base of natural logarithms) raised to the power of Val. If the current data value is NULL, Val is 0.0 and the return value is 1.0.
When Val is a large number, the return value can have more digits than can be accurately represented by the Double data type. However, the function does not check for this and does not issue an error when this happens. This function is therefore unsuitable for use with positive values greater than about 709 or negative values less than about -745.
This function is similar to the Exp function in VBScript.
Example
The following mrScriptBasic example uses the Exp function to return e raised to a power:
Dim MyNumber, MyBigNumber1, MyBigNumber2, MyBigNegativeNumber1, MyBigNegativeNumber2

MyNumber = Exp(1.32581766366803) ' Returns 3.76526281526936
MyBigNumber1 = Exp(709.782712893) ' Returns 1.79769313417214E+308
MyBigNumber2 = Exp(709.782712894) ' Returns 1.#INF, which indicates "overflow"
MyBigNegativeNumber1 = Exp(-744.44007) ' Returns 4.94065645841247E-324
MyBigNegativeNumber2 = Exp(-745.2) ' Returns 0, which indicates "underflow"
The following example demonstrates using the Exp and Log functions to return x to the power of y (when x is greater than zero):
Dim x, y, XToThePowerOfY
XToThePowerOfY = Exp(Log(x) * y)
This example is not suitable when x is negative because the parameter to the Log function must be a positive number.
The following example demonstrates using the Exp and Log functions to return the cube root of x:
Dim x, CubeRootOfX

If x > 0 Then
  CubeRootOfX = Exp(Log(x) / 3)
ElseIf x < 0 Then
  CubeRootOfX = - Exp(Log(-x) / 3)
Else
  CubeRootOfX = 0
End If
See also
Log
Mathematical functions