[Previous]
[Contents]
[Next]

log2()

compute the logarithm (base 2) of a number

Synopsis:

#include <math.h>
double log2( double x );

Description:

The log2() function computes the logarithm (base 2) of x. A domain error occurs if the argument is negative. A range error occurs if the argument is zero.

Returns:

The logarithm (base 2) of the argument.

When the argument is outside the permissible range, the matherr() function is called. Unless the default matherr() function is replaced, it will set the global variable errno to EDOM, and print a "DOMAIN error" diagnostic message using the stderr stream.

Examples:

#include <stdio.h>
#include <math.h>

void main()
  {
    printf( "%f\n", log2(.25) );
  }

produces the output:

-2.000000

Classification:

WATCOM

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, exp(), log(), log10(), pow(), matherr()


[Previous]
[Contents]
[Next]