^ Operator
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

^ Operator

Raises a number to the power of another number.

Number ^ exponent

Parts

number
Required. Any numeric expression.
exponent
Required. Any numeric expression.

Result

The result value will be number raised to the exponent power.

Supported Types

Double. All operands of a different type will be converted to Double.

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 Double.

Example

This example uses the ^ operator to raise a number to the power of an exponent. The result is the first operand raised to the power of the second.

Dim myValue As Double
myValue = 2 ^ 2   ' Returns 4.
myValue = 3 ^ 3 ^ 3   ' Returns 19683.
myValue = (-5) ^ 3   ' Returns -125.
myValue = (-5) ^ 4   ' Returns 625.

See Also

^= Operator | Arithmetic Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Arithmetic Operators

Show:
© 2016 Microsoft