DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

log(3M)


ilogb, log, log1p, log2, log10, logb -- logarithm functions

Synopsis

   cc [flag . . .] file . . . -lm [library . . .]
   

#include <math.h>

int ilogb(double x);

int ilogbf(float x);

int ilogbl(long double x);

double log(double x);

float logf(float x);

long double logl(long double x);

double log1p(double x);

float log1pf(float x);

long double log1pl(long double x);

double log2(double x);

float log2f(float x);

long double log2l(long double x);

double log10(double x);

float log10f(float x);

long double log10l(long double x);

double logb(double x);

float logbf(float x);

long double logbl(long double x);

Description

ilogb, ilogbf and ilogbl extract the exponent of x as a signed int value. If x is zero they compute the value FP_ILOGB0; if x is infinite they compute the value INT_MAX; if x is a NaN they compute the value FP_ILOGBNAN; otherwise, they are equivalent to calling the corresponding logb function and casting the returned value to type int. A range error occurs if x is 0.

log, logf and logl return the natural logarithm of x. The value of x must be positive.

log1p, log1pf and log1pl return the natural logarithm of 1.0+x. The value of x must be greater than -1.0.

log2, log2f and log2l return the base two logarithm of x. The value of x must be positive.

log10, log10f and log10l return the base ten logarithm of x. The value of x must be positive.

logb, logbf and logbl return the signed exponent of x.

Errors

log, log2 and log10 (and their floating and long double equivalents) return a value that compares equal to -HUGE_VAL, -HUGE_VALF or -HUGE_VALL (respectively) and set errno to ERANGE when x is ±0. On systems that support IEEE floating-point, the divide by zero exception is raised.

loglp, loglpf and loglpl return a value that compares equal to -HUGE_VAL, -HUGE_VALF or -HUGE_VALL and set errno to ERANGE when x is -1. On systems that support IEEE floating-point, the divide by zero exception is raised.

If x is negative, log, log2 and log10 (and their floating and long double equivalents) return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return zero and set errno to EDOM.

If x is less than -1, loglp, loglpf and loglpl return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return zero and set errno to EDOM.

On systems that support IEEE NaN, if any of the inputs to each of these functions is a quiet NaN, that value is returned. If any input is a signaling NaN, a quiet NaN is returned and the invalid operation exception is raised. In either case, errno is set to EDOM.

If the program was compiled with the -Xt compilation mode, a value that will compare equal to ±HUGE is returned instead of ±HUGE_VAL. log, log2 and log10 (and their floating and long double equivalents) return a value that compares equal to -HUGE for non-positive arguments and set errno to EDOM. In addition, a message indicating DOMAIN error is printed on the standard error output. These error handling procedures can be changed with the function matherr.

References

cc(1), matherr(3M),
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004