HPlogo HP-UX Reference Volume 4 of 5 > l

log2(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

log2(), log2f() — logarithm base two functions

SYNOPSIS

#include <math.h>

double log2(double x);

float log2f(float x);

DESCRIPTION

log2() returns the logarithm base two of x. The value of x must be greater than zero.

The ISO/ANSI C committee has approved the log2() function for inclusion in the C9X draft standard.

log2f() is a float version of log2(); it takes a float argument and returns a float result.

log2f() is not specified by any standard, but it is named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard.

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options. Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

If x is +INFINITY, log2() returns +INFINITY.

If x is zero, log2() returns -HUGE_VAL.

If x is NaN, log2() returns NaN.

If x is less than zero, log2() returns NaN and sets errno to [EDOM].

ERRORS

If log2() fails, errno is set to the following value.

[EDOM]

x is less than zero.

© Hewlett-Packard Development Company, L.P.