Skip to content

nextpow2

general · scripts/general/nextpow2.m

: p = nextpow2 (a)

Return the smallest integer p such that 2^p >= abs (a), element by element.

The exponent is read from the binary floating point representation, so exact powers of two are never misjudged. nextpow2 (0) is 0, infinite values give Inf and NaN gives NaN.