Index-> contents reference index search Up-> SPT_HELP Mathematical Functions powerof2 Prev Next SPT_HELP-> SPTFunctionsByCategory Mathematical Functions Data Manipulation Functions SignalGeneratorMain AnalogFilterFunctions FIR Filter Design Window Functions IIR Filter Design FourierFunctions Plotting Functions Histogram Functions Mathematical Functions-> colavg colmsq colrms db10 db20 even logn powerof2 OtherMathStat sinc powerof2 Headings-> Description Example

Determine if a Number is a Power-of-2
 Syntax `y = powerof2(`x`)` Include: `include spt\powerof2.oms` See Also
``` ARGUMENTS:     INPUTS:          x = MATRIX, any numerical type.     RETURN: MATRIX,INTEGER, 1=power-of-2, 0=otherwise ```
Description ``` ```Determines on an element-by-element basis whether input values are an integral power-of-2. Any numerical type may be input. All values are coerced to DOUBLE before local processing. All input values must be strictly positive or 'novalue' is returned. An INTEGER matrix is returned where each element is a "1" if the input entry was a power-of-2, returns 0 otherwise.

Example ``` ```For Sclars: ``` O>powerof2(1/8192.)  1  ``` For Vector Input: ``` O>x = {.125, 1, 5, 8, 128, 200} O>powerof2(x) {  1  1  0  1  1  0 } ``` For Matrices: ``` O>A = {[.25, 32], [.1, 100]} O>powerof2(A) { [  1 ,  1 ] [  0 ,  0 ] } ``` Error Response: ``` O>x = powerof2({0.0, -1}) ERROR: powerof2(), Contains non-positive elements.         Returning 'novalue'.  O>type(x) novalue  ```