Skip to content

Commit

Permalink
Update pow.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgunnlsgunn authored Nov 4, 2024
1 parent c0c1861 commit 427c434
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docs/builtins/Operators/pow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## power-of (^)

Use `^` to raises the `oper1` argument to the power of the `oper2` argument.
Use the exponentiation operator `^` to raise the `oper1` argument to the power of the `oper2` argument.
You can use this operator with both integer or decimal values.
When the operands are integers, the result is an integer if the exponent is not negative.
When the operands are decimals or you use a negative exponent, the result is always a decimal.

### Basic syntax

Expand All @@ -25,9 +28,23 @@ The `^` function returns the result of raising `oper1` to the power of `oper2`.

### Examples

The following example demonstrates how to use the `^` function to raise `2` to the power of `3` in a Pact REPL:
The following example demonstrates how to use the `^` function with integer values to raise `2` to the power of `3` in a Pact REPL:

```pact
pact> (^ 2 3)
8
```

The following example demonstrates how to use the `^` function with decimal values to raise `5.5` to the power of `2.0` in a Pact REPL:

```pact
pact> (^ 5.5 2.0)
30.25
```

The following example demonstrates using the `^` function with a negative exponent value:

```pact
pact> (^ 2 -3)
0.125
```

0 comments on commit 427c434

Please sign in to comment.