case 9:
if (lb!=0)
{
lc = log(lb);
}
break;
I m using 'log' function in C++, do I need a special lib?
log
%26lt;math.h%26gt;
double log ( double x );
Calculate natural logarithm.
Returns the natural logarithm of parameter x.
Parameters.
x
Floating point value.
Return Value.
Logarithm of x.
Portability.
Defined in ANSI-C.
ANSI-C++ adds float and double overloaded versions of this function, with the same bahavior but being both, parameter and result, of one of these types.
Example.
/* log example */
#include %26lt;stdio.h%26gt;
#include %26lt;math.h%26gt;
int main ()
{
double param, result;
param = 5.5;
result = log (param);
printf ("ln(%lf) = %lf\n", param, result );
return 0;
}
Output:
ln(5.500000) = 1.704748
Reply:yes, include the line below in your source code:
#include%26lt;math.h%26gt;
Reply:You code module needs to #include %26lt;math.h%26gt; to get the function prototype for the log function. You will also need to ensure the compiled object module is linked with the math library (libm.a). In a UNIX environment put a -lm argument on the linker command.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment