Syntax
|
expression1
^
expression2
|
Description
|
Returns expression1 raised to the power specified in expression2.
|
Comments
|
The following are special cases:
|
|
Special Case
|
Value
|
|
n^0
|
1
|
|
0^-n
|
Undefined
|
|
0^+n
|
0
|
|
1^n
|
1
|
|
The type of the result is always Double, except with Boolean expressions, in which case the result is Boolean. Fractional and negative exponents are allowed.
If either expression is a Variant containing NULL, then the result is NULL.
It is important to note that raising a number to a negative exponent produces a fractional result.
|
Example
|
Sub Main()
s# = 2 ^ 5 'Returns 2 to the 5th power.
r# = 16 ^ .5 'Returns the square root of 16.
MsgBox "2 to the 5th power is: " & s#
MsgBox "The square root of 16 is: " & r#
End Sub
|
See Also
|
Operator Precedence (topic).
|