log, logl

De RAD Studio
Aller à : navigation, rechercher

Remonter à Math.h - Index


Header File

math.h

Category

Math Routines

Prototype

double log(double x);

long double logl(long double x);

Description

Calculates the natural logarithm of x.

log calculates the natural logarithm of x.

logl is the long double version; it takes a long double argument and returns a long double result.

Return Value

On success, log and logl return the value calculated, ln(x).

errno

EDOM

Domain error



If x is 0, the functions return the value negative HUGE_VAL (log) or negative _LHUGE_VAL (logl), and set errno to ERANGE. Error handling for these routines can be modified through the functions _matherr and _matherrl.

Example



 #include <math.h>
 #include <stdio.h>
 int main(void)
 {
    double result;
    double x = 8.6872;
    result = log(x);
    printf("The natural log of %lf is %lf\n", x, result);
    return 0;
 }



Portability



POSIX Win32 ANSI C ANSI C++

log

+

+

+

+

logl

+

+

+