# log2

## Purpose

Dissect floating-point numbers.

## Synopsis

    Y = log2(X)
    [F,E] = log2(X)

## Description

`log2(X)` computes the base 2 logarithm of the elements of `X`.

`[F,E] = log2(X)` for a real matrix `X`, returns a matrix `F` of real numbers, usually in the range `0.5 <= abs(F) < 1`, and a matrix `E` of integers, so that `X = F.`*`2.^E`. Any zeros in `X` produce `F = 0` and `E = 0`.

This function corresponds to the ANSI C function `frexp()` and the IEEE floating-point standard function `logb()`.

## Examples

For IEEE arithmetic, the statement `[F,E] = log2(X)` yields the following values.

        X         F         E

        1         1/2       1
        pi        pi/4      2
        -3        -3/4      2
        eps       1/2       -51
        realmax   1-eps/2   1024
        realmin   1/2       -1021

## See Also

    format hex, log, pow2, realmax, realmin

(c) Copyright 1994 by The MathWorks, Inc.