R: MATLAB nextpow2 function

nextpow2 {matlab} | R Documentation

## MATLAB nextpow2 function

### Description

Smallest power of 2 greater than or equal to its argument.

### Usage

    nextpow2(x)

### Arguments

`x` | numeric or complex value(s).

### Details

Computes the smallest power of two that is greater than or equal to the absolute value of `x`. (That is, `p` that satisfies 2^p ≥ abs(x)). For negative or complex values, the absolute value will be taken.

### Value

Returns numeric result containing integer `p` as described above. Nonscalar input returns an element-by-element result (of same size/dimensions as its input).

### Author(s)

H. Borchers hwborchers@googlemail.com, P. Roebuck proebuck@mdanderson.org

### See Also

`pow2`

### Examples

    nextpow2(10)                   # 4
    nextpow2(1:10)                 # 0 1 2 2 3 3 3 3 4 4
    nextpow2(-2^10)                # 10
    nextpow2(.Machine$double.eps)  # -52
    nextpow2(c(0.5, 0.25, 0.125))  # -1 -2 -3

[Package matlab version 1.0.2 Index]