next_power_of_2

Returns the smallest power of 2 greater or equal to i.

Namespace: dsp

Prototype

int next_power_of_2(unsigned int i)

Description

Computes the smallest power of 2 greater or equal to \(i\): \[ y = \min_{j\geq i,\ j = 2^k} j \]

Example

assertion(next_power_of_2(3) == 4);