HPlogo HP-UX Reference > L

log2(3M)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

log2(), log2f(), log2l(), log2w(), log2q() — logarithm base two functions

SYNOPSIS

#include <math.h>

double log2(double x);

float log2f(float x);

Itanium(R)-based System Only

long double log2l(long double x);

extended log2w(extended x);

quad log2q(quad x);

DESCRIPTION

log2() returns the logarithm base two of x.

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

Itanium-based System Only

log2l() is a long double version of log2(); it takes a long double argument and returns a long double result.

log2w() is an extended version of log2(); it takes an extended argument and returns an extended result.

log2q() is equivalent to log2l() on HP-UX systems.

USAGE

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Itanium-based systems) log2w() or log2q(), compile also with the -fpwidetypes option.

Make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

For more information, see the HP-UX Floating-Point Guide.

RETURN VALUE

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

If x is zero, log2() returns -HUGE_VAL (equal to -INFINITY) and raises the divide-by-zero exception.

If x is less than zero, log2() returns NaN and raises the invalid exception.

If x is NaN, log2() returns NaN.

log2() raises the inexact exception whenever a rounded result does not equal the mathematical result.

ERRORS

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

Itanium-based System Only

HP-UX libm functions on Itanium-based systems do not set errno by default. For errno setting, compile with the +Olibmerrno option.

STANDARDS CONFORMANCE

log2(), log2f(), log2l() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')