English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

C Standard Library <math.h>

The C <math.h> header file declares a set of functions to perform mathematical operations, such as: sqrt() calculates the square root, log() finds the natural logarithm of a number, etc.       

math.h The header file defines various mathematical functions and a macro. All available functions in this library have a double Type of parameters, and all return double Type of result.

Library Macro

The following is the only macro defined in this library:

Serial NumberMacro & Description
1HUGE_VAL

When the result of the function cannot be represented as a floating-point number. If it is because the magnitude of the result is too large to be represented, the function will set errno to ERANGE to indicate a range error, and return a value by the macro HUGE_VAL or its negation (- HUGE_VAL) named a specific very large value.

If the magnitude of the result is too small, zero will be returned. In this case, error may be set to ERANGE, or it may not be set to ERANGE.

Library Functions

The following lists the functions defined in the header file math.h:

Serial NumberFunction & Description
1double acos(double x)
Returns the arccosine of x, expressed in radians.
2double asin(double x)
Returns the arcsine of x, expressed in radians.
3double atan(double x)
Returns the arctangent of x, expressed in radians.
4double atan2(double y, double x)
Returns the arctangent of y, expressed in radians/The arctangent of x. The signs of y and x determine the correct quadrant.
5double cos(double x)
Returns the cosine of the radian angle x.
6double cosh(double x)
Returns the hyperbolic cosine of x.
7double sin(double x)
Returns the sine of the radian angle x.
8double sinh(double x)
Returns the hyperbolic sine of x.
9double tanh(double x)
Returns the hyperbolic tangent of x.
10double exp(double x)
Returns the value of e raised to the power of x.
11double frexp(double x, int *exponent)
Decomposes the floating-point number x into a mantissa and an exponent. The returned value is the mantissa, and the exponent is stored in exponent. The value is x = mantissa * 2 ^ exponent.
12double ldexp(double x, int exponent)
Returns x multiplied by 2 to the power of exponent.
13double log(double x)
Returns the natural logarithm (base e) of x.
14double log10(double x)
Returns the common logarithm (base 10) of x. 10 logarithm).
15double modf(double x, double *integer)
Returns the fractional part (the part after the decimal point) of the value, and sets integer to the integer part.
16double pow(double x, double y)
Returns x raised to the power of y.
17double sqrt(double x)
Returns the square root of x.
18double ceil(double x)
Returns the smallest integer greater than or equal to x.
19double fabs(double x)
Returns the absolute value of x.
20double floor(double x)
Returns the largest integer less than or equal to x.
21double acosh(double x)
Returns the inverse hyperbolic cosine of x, expressed in radians.
22double fmod(double x, double y)
Returns the remainder of x divided by y.
23double asinh(double x)
Returns the inverse hyperbolic sine of the parameter.
24double atanh(double x)
Returns the inverse hyperbolic tangent of the parameter.
25double hypot(double p, double b)
Calculate the hypotenuse of a right triangle.