Skip to content

next_pow2

Vašek edited this page Feb 5, 2019 · 1 revision

next_pow2

This function returns the smallest power of two that is greater than or equal to the given number

Syntax:

next_pow2(n)
Argument Description
int n The given number

Returns: int

Description:

This function returns the smallest power of two that is greater than or equal to the given n number.

Example:

int value = next_pow2(128);

128 is already power of 2 - this function will set value to 128.

Example 2:

int value = next_pow2(300);

Nearest power of two that is higher than 300 is 512 - this function will set value to 512.

Back to number_functions

Clone this wiki locally