A method of using logarithmic functions in C language _c language

Source: Internet
Author: User
Tags error code numeric numeric value

C Language Log () function: Returns an e-base pair value
header file:

#include <math.h>

The log () function returns an e-base numeric value, which is a prototype:

 Double log (double x);

Log () is used to calculate the pair value of x with an E, and then returns the result. Set the return value to RET, the

x = Eret

If x is negative or 0, an error occurs and the errno value is set. Error code:
EDOM: parameter x is negative;
Erange: Parameter x is zero value, 0 is undefined for value.

Note: Please join-LM when compiling with GCC.

"Instance" to find the logarithm of 5.5.

#include <stdio.h>
#include <math.h>
int main ()
{
 double param, result;
 param = 5.5;
 result = log (param);
 printf ("log (%f) =%f\n", param, result);
 return 0;
}

Output results:

Log (5.500000) = 1.704748

C language log10 () function: Returns a value of 10
header file:

#include <math.h>

LOG10 () returns a 10-based numeric value, which is a prototype:

 Double log10 (double x);

LOG10 () is used to calculate the pair value of a 10-based x, and then returns the result. Set the return value to RET, the

x = 10ret

Return value: Returns the numeric value of the argument x with a 10 base.

If x is negative or 0, an error occurs and the errno value is set. Error code:
EDOM: parameter x is negative;
Erange: Parameter x is zero value, 0 is undefined for value.

Note: Please join-LM when compiling with GCC.

Instance

#include <math.h>
Main () {
 double answer;
 Answer = log10 (MB);
 printf ("log10" =%f\n ", answer);
}

Output results:

LOG10 (100) = 2.000000

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.