The ALOG2 function returns the logarithm to the base 2 of X.

For input of a complex number, Z = X + iY, the complex number can be rewritten as Z = R exp(iq), where R = abs(Z) and q = atan(y,x). The complex log base 2 is then given by,

alog2(Z) = alog2(R) + i q/alog(2)

In the above formula, the use of the two-argument arctangent separates the solutions at Y = 0 and takes into account the branch-cut discontinuity along the real axis from -∞ to 0, and ensures that 2^(alog2(Z)) is equal to Z 1. For details see formulas 4.4.1-3 in Abramowitz, M. and Stegun, I.A., 1964: Handbook of Mathematical Functions (Washington: National Bureau of Standards).

## Examples

Find the base 2 logarithm of 100 and print the result by entering:

`PRINT, ALOG2(100)`

IDL prints:

`6.64386`

## Syntax

Result = ALOG2(X)

## Return Value

Returns the logarithm to the base 2 of X.

## Arguments

### X

The value for which the base 2 log is desired. For real input, X should be greater than or equal to zero. If X is double-precision floating or complex, the result is of the same type. All other types are converted to single-precision floating-point and yield floating-point results. If X is an array, the result has the same dimensions, with each element containing the base 2 log of the corresponding element of X.