#### Revision [12392]

This is an old revision of KeyPgOpExponentiate made by JeffMarshall on 2008-01-18 14:20:39.

### Operator ^ (Exponentiate)

Raises a numeric expression to some power

**Syntax:**

**Usage:**

*result*=*lhs***^**

*rhs*

**Parameters:**

*lhs*
The left-hand side base expression.

*rhs*
The right-hand side exponent expression.

**Return Value:**

Returns the exponentiation of a base expression raised to some exponent.

**Description:**

**returns the result of a base expression (**

`Operator ^`(Exponentiate)`) raised to some exponent expression (`

*lhs*`).`

*rhs***^**works with double float numbers only, operands of other types will be converted into double before performing the exponentiation. Exponent of a fractional value (1/n) is the same as taking n-th root from the base, for example, 2

**^**(1/3) is the cubed root of 2.

Neither of the operands are modified in any way.

This operator can be overloaded for user-defined types.

**Examples:**

Dim As Double n

Input "Please enter a positive number: ", n

Print

Print n;" squared is "; n ^ 2

Print "The fifth root of "; n;" is "; n ^ 0.2

Sleep

Input "Please enter a positive number: ", n

Print n;" squared is "; n ^ 2

Print "The fifth root of "; n;" is "; n ^ 0.2

Sleep

Output:

Please enter a positive number: 3.4 3.4 squared is 11.56 The fifth root of 3.4 is 1.27730844458754

**Dialect Differences:**

- In the
*CompilerOptlang -lang qb*dialect, this operator cannot be overloaded.

**Differences from QB:**

- None

**See also:**

Back to Arithmetic Operators

Back to Operators