> For the complete documentation index, see [llms.txt](https://docs.urbit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.urbit.org/hoon/stdlib/2g.md).

# 2g: Unsigned Powers

## `+pow` <a href="#pow" id="pow"></a>

Computes `.a` raised to the power of `.b`, producing an `$atom`.

#### Accepts

`.a` is an `$atom`.

`.b` is an `$atom`.

#### Produces

An `$atom`.

#### Source

```hoon
++  pow
  ~/  %pow
  |=  [a=@ b=@]
  ?:  =(b 0)  1
  |-  ?:  =(b 1)  a
  =+  c=$(b (div b 2))
  =+  d=(mul c c)
  ?~  (dis b 1)  d  (mul d a)
```

#### Examples

```
> (pow 2 6)
64
```

```
> (pow 6 2)
36
```

```
> (pow 7 (add 2 2))
2.401
```

```
> (pow 2 0)
1
```

```
> `@ux`(pow 0x1b 2)
0x2d9
```

***

## `+sqt` <a href="#sqt" id="sqt"></a>

Computes the square root of `.a` and its remainder.

#### Accepts

`.a` is an `$atom`.

#### Produces

A cell of `$atom`s.

#### Source

```hoon
++  sqt
  ~/  %sqt
  |=  a=@  ^-  [p=@ q=@]
  ?~  a  [0 0]
  =+  [q=(div (dec (xeb a)) 2) r=0]
  =-  [-.b (sub a +.b)]
  ^=  b  |-
  =+  s=(add r (bex q))
  =+  t=(mul s s)
  ?:  =(q 0)
    ?:((lte t a) [s t] [r (mul r r)])
  ?:  (lte t a)
    $(r s, q (dec q))
  $(q (dec q))
```

#### Examples

```
> (sqt 4)
[p=2 q=0]
```

```
> (sqt 6)
[p=2 q=2]
```

```
> (sqt 2)
[p=1 q=1]
```

```
> (sqt 0b1101)
[p=3 q=4]
```

```
> `@ux`(sqt 0b1101)
! exit
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.urbit.org/hoon/stdlib/2g.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
