^ Operator

Description

Used to raise a number to the power of an exponent.

Syntax

result = number^exponent

The ^ operator syntax has these parts:

Part Description
result Any numeric variable.
number Any numeric expression.
exponent Any numeric expression.


Remarks

Number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.

Usually, the data type of result is a Double or a Variant containing a Double. However, if either number or exponent is a Null expression, result is also Null.

See Also

Operator Precedence.

Example

This example uses the ^ operator to raise a number to the power of an exponent.


MyValue = 2 ^ 2                ' Returns 4.= 3 ^ 3 ^ 3            ' Returns 19683.= (-5) ^ 3            ' Returns -125.