Next Power of Two

Find the next power of two greater than or equal to a given number.

Code

General
$n <= 1 ? 1 : pow(2, ceil(log($n, 2)));

Parameters

Number

Server

More PHP Snippets