# math.nextPowerOfTwo

Function · category: Math

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/core/math/math.js#L207

```ts
nextPowerOfTwo(val: number): number
```

Returns the next power of 2 for the specified value.

**Parameters**

- `val` (`number`): The value for which to calculate the next power of 2.

**Returns** `number`: The next power of 2.

**Example**

```ts
math.nextPowerOfTwo(17); // returns 32
math.nextPowerOfTwo(32); // returns 32
```
