[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

log2, log2f, or log2l Subroutine

Purpose

Computes base 2 logarithm.

Syntax

#include <math.h>

double log2 (x)
double x;

float log2f (x)
float x;

long double log2l (x)
long double x;

Description

The log2, log2f, and log2l subroutines compute the base 2 logarithm of the x parameter, log2 (x).

An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

x Specifies the value to be computed.

Return Values

Upon successful completion, the log2, log2f, and log2l subroutines return the base 2 logarithm of x.

If x is ±0, a pole error occurs and the log2, log2f, and log2l subroutines return -HUGE_VAL, -HUGE_VALF, and -HUGE_VALL, respectively.

For finite values of x that are less than 0, or if x is -Inf, a domain error occurs, and a NaN is returned.

If x is NaN, a NaN is returned.

If x is 1, +0 is returned.

If x is +Inf, x is returned.

Related Information

feclearexcept Subroutine and fetestexcept Subroutine.

math.h in AIX 5L Version 5.2 Files Reference.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]