C Standard Library - <math.h>


Introduction

math.h The header file defines various mathematical functions and a macro. All functions available in this library take a parameter of type double and return a result of type double.

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 the magnitude of the result is too large to be represented, the function sets errno to ERANGE to indicate a range error, and returns a specific large value named by the macro HUGE_VAL or its negation (-HUGE_VAL).

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

Library functions

The functions defined in the header file math.h are listed below:

Serial numberFunction & Description
1double acos(double x)
Returns the inverse cosine of x in radians.
2double asin(double x)
Returns the arcsine of x in radians.
3double atan(double x)
Returns the arctangent of x in radians.
4double atan2(double y, double x)
Returns the arctangent of y/x in radians. The sign of the y and x values ​​determines the correct quadrant.
5double cos(double x)
Returns the cosine of the angle x in radians.
6double cosh(double x)
Returns the hyperbolic cosine of x.
7double sin(double x)
Returns the sine of the angle x in radians.
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)
Decompose the floating point number x into mantissa and exponent. The return value is the mantissa and the exponent is stored in exponent. The resulting value is x = mantissa * 2 ^ exponent.
12double ldexp(double x, int exponent)
Returns x multiplied by 2 raised to the exponent power.
13double log(double x)
Returns the natural logarithm of x (logarithm of base e).
14double log10(double x)
Returns the common logarithm of x (base 10 logarithm).
15double modf(double x, double *integer)
The return value is the decimal part (the part after the decimal point), and the integer is set to the integer part .
16double pow(double x, double y)
Returns x raised to the y power.
17double sqrt(double x)
Returns the square root of x.
18double ceil(double x)
Returns the smallest integer value greater than or equal to x.
19double fabs(double x)
Returns the absolute value of x.
20double floor(double x)
Returns the largest integer value less than or equal to x.
21double fmod(double x, double y)
Returns the remainder of x divided by y.