Calculate logarithms.
#include <math.h>
double log( double x );
double log10( double x );
long double _logl( long double x );
long double _log10l( long double x );
x | Value whose logarithm is to be found |
The log and log10 functions calculate the natural logarithm and the base-10 logarithm, respectively, of x. The _logl and _log10l functions are the 80-bit counterparts and use the 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.
The log functions return the logarithm of the argument x. If x is negative, the functions print a _DOMAIN error message to stderr, return the value –HUGE_VAL, and set errno to EDOM. If x is 0, the functions print a _SING error message to stderr, return the value –HUGE_VAL, and set errno to ERANGE.
Error handling can be modified by using the _matherr or _matherrl routine.
log, log10
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_logl, _log10l
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* LOG.C: This program uses log and log10 to calculate the natural
* logarithm and the base-10 logarithm of 9,000.
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 9000.0;
double y;
y = log( x );
printf( "log( %.2f ) = %f\n", x, y );
y = log10( x );
printf( "log10( %.2f ) = %f\n", x, y );
}
log( 9000.00 ) = 9.104980
log10( 9000.00 ) = 3.954243