LOG2(3) NEWLIB LOG2(3)NAME
1.36 `log2', `log2f'-base 2 logarithm
SYNOPSIS
#include <math.h>
double log2(double X);
float log2f(float X);
DESCRIPTION
The `log2' functions compute the base-2 logarithm of X. A domain error
occurs if the argument is less than zero. A range error occurs if the
argument is zero.
The Newlib implementations are not full, intrinisic calculations,
but rather are derivatives based on `log'. (Accuracy might be slightly
off from a direct calculation.) In addition to functions, they are
also implemented as macros defined in math.h:
#define log2(x) (log (x) / _M_LOG2_E)
#define log2f(x) (logf (x) / (float) _M_LOG2_E)
To use the functions instead, just undefine the macros first.
You can use the (non-ANSI) function `matherr' to specify error han‐
dling for these functions, indirectly through the respective `log'
function.
RETURNS
The `log2' functions return `log base-2(X)' on success. When X is
zero, the returned value is `-HUGE_VAL' and `errno' is set to `ERANGE'.
When X is negative, the returned value is NaN (not a number) and
`errno' is set to `EDOM'. You can control the error behavior via
`matherr'.
PORTABILITY
C99, POSIX, System V Interface Definition (Issue 6).
SEE ALSOlog2 is part of the library. The full documentation for is maintained
as a Texinfo manual. If info and are properly installed at your site,
the command
info
will give you access to the complete manual.
NEWLIB April 2010 LOG2(3)