You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

next_pow2

Returns the next power-of-two greater than or equal to a given value.

n = next_pow2(1010);    //  n == 1024
n = next_pow2(1024);    //  n == 1024
n = next_pow2(1030);    //  n == 2048
next_pow2(n)
Returns the next power-of-two greater than or equal to a given value.
COPY/// next_pow2(n)
//
//  Returns the next power-of-two greater than or equal to a given value.
//
//      n       positive integer
//
/// GMLscripts.com/license
{
    return 1 << ceil(log2(argument0));
}

Contributors: davesch, xot

GitHub: View · Commits · Blame · Raw