log, logf, logl, logd32, logd64, and logd128 Subroutines

Purpose

Computes the natural logarithm.

Syntax

#include <math.h>

float logf (x)
float x;

long double logl (x)
long double x;

double log (x)
double x;
_Decimal32 logd32 (x)
_Decimal32 x;

_Decimal64 logd64 (x)
_Decimal64 x;

_Decimal128 logd128 (x)
_Decimal128 x;

Description

The logf, logl, log, logd32, logd64, and logd128 subroutines compute the natural logarithm of the x parameter, loge (x).

An application wishing to check for error situations should set the errno global variable 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

Item Description
x Specifies the value to be computed.

Return Values

Upon successful completion, the logf, logl, log, logd32, logd64, and logd128 subroutines return the natural logarithm of x.

If x is ±0, a pole error occurs and the logf, logl, and log subroutines return -HUGE_VALF and -HUGE_VALL, -HUGE_VAL, HUGE_VAL_D32, HUGE_VAL_D64, and HUGE_VAL_D128 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.

Error Codes

When using the libm.a library:

Item Description
log If the x parameter is less than 0, the log subroutine returns a NaNQ value and sets errno to EDOM. If x= 0, the log subroutine returns a -HUGE_VAL value but does not modify errno.

When using libmsaa.a(-lmsaa):

Item Description
log If the x parameter is not positive, the log subroutine returns a -HUGE_VAL value, and sets errno to a EDOM value. A message indicating DOMAIN error (or SING error when x = 0) is output to standard error.
log If x<0, the logl subroutine returns a NaNQ value