![]() Chapter Contents |
![]() Previous |
![]() Next |
| log |
| Portability: | ISO/ANSI C conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| DIAGNOSTICS | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <math.h> double log(double x);
| DESCRIPTION |
log
computes the natural log of its argument
x
.
The
x
argument must be a positive double-precision,
floating-point number. The natural log is the inverse of the exponential
function.
| RETURN VALUE |
log
returns the natural log of its argument
x
,
expressed as a double-precision, floating-point number.
| DIAGNOSTICS |
The run-time library writes an error message
to the standard error file (
stderr
) if
x
is a negative number or 0. In this case, the
function returns
-HUGE_VAL
, the largest
negative floating-point number that can be represented.
If an error occurs in
log
, the
_matherr
routine is called.
You supply your own version of
_matherr
to suppress the diagnostic message or modify the value returned.
| EXAMPLE |
This example computes the natural log
of 10, using
log
:
#include <math.h>
#include <stdio.h>
main()
{
double y, val;
val = 10.0;
y = log(val);
printf("log(%f) = %f\n", val, y);
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.