> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/e/exponentiation_operator.md).

# Exponentiation operator

Function definition:

```ruby
func expon(_, { .is_zero }) { 1 }

func expon(base, exp { .is_neg }) {
    expon(1/base, -exp)
}

func expon(base, exp { .is_int }) {

  var c = 1
  while (exp > 1) {
    c *= base if exp.is_odd
    base *= base
    exp >>= 1
  }

  return (base * c)
}

say expon(3, 10)
say expon(5.5, -3)
```

Operator definition:

```ruby
class Number {
    method ⊙(exp) {
        expon(self, exp)
    }
}

say (3 ⊙ 10)
say (5.5 ⊙ -3)
```

#### Output:

```
59049
0.0060105184072126220886551465063861758076634109692
```
