^ Operator

Raises a number to a power.

Syntax

number ^ exponent

Parts

number
A numeric expression.
exponent
A numeric expression.

Result

The result is number raised to the power of exponent. Its data type can be one of Real64 or Real128. See Data Types of Operator Results for more information.

Applicable types

If the operands are not one of Real64 or Real128, they will be converted to one of these.

Instructions

The value of exponent can be fractional and/or negative.

If an expression has more than one caret operator, they are read from right to left.

Note: ViviFire's caret operator has precedence rules different from standard mathematics. Standard mathematics gives exponentiation precedence above negation. ViviFire gives unary operators (negation included) precedence above the caret operator. Thus, “−3²” must be coded as “-(3^2)”.

Examples

ExampleResult
2 ^ 3
8.0
-2 ^ 3
-8.0
-2 ^ 4
16.0
4 ^ 3 ^ 2
262144.0
4 ^ -2
0.0625
16 ^ 0.5
4.0
9 ^ -0.5
0.33333333333333333333333333333333