Linux C library functions encyclopedia: Mathematical Functions

Source: Internet
Author: User
Tags abs acos error code header mathematical functions printf range linux

1.abs (Calculate the absolute value of the integer number)

Related functions:

Labs, Fabs

Table header file:

#include <math.h>

To define a function:

int abs (int j)

Function Description:

ABS () is used to calculate the absolute value of the parameter J, and then return the result.

return value:

Returns the absolute result of the parameter J.

Example:

#include <stdio.h> 
#include <math.h> 
main () 
    { 
        int answer; 
        Answer = ABS ( -12); 
        printf ("|-12| =%d\n ", answer); 
    }

2.acos (Take the inverse cosine function value)

Related functions:

ASIN, ATAN, atan2, cos, sin, tan

Table header file:

#include <math.h>

To define a function:

Double ACOs (double x);

Function Description:

ACOs () is used to calculate the inverse cosine of the parameter x, and then returns the result. The parameter x range is between 1 and 1 and will fail if it exceeds this range.

return value:

Returns the calculated result between 0 and pi, in radians, in radians in the function library.

Error code:

Edom parameter x is out of range.

Example:

#include <stdio.h> 
#include <math.h> 
main () 
    { 
        double angle; 
        Angle = ACOs (0.5); 
        printf ("angle =%f\n", angle); 
    }

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.