math.h C Library Functions

The math.h header file includes C standard library functions to perform common mathematical operations and transformations. It contains Trigonometric, Exponential, logarithmic, Rounding off functions etc.

All the functions math.h library take double as input argument and return a double. Even if we pass a float value, it gets promoted(type casted) to a double value.

List of math.h Library Functions

Click on function names below to see detailed description of functions.

Function Description
acos It returns the arc cosine in radians.
asin() It returns the arc sine in radians.
atan It returns the arc tangent in radians.
atan2 It returns the arc tangent with two parameters.
ceil It returns the smallest integer value greater than or equal to x.
cos It returns the cosine of an angle in radians.
cosh It returns the hyperbolic cosine.
exp It returns the value of e raised to the power of x(ex).
fabs It returns the absolute value of x.
floor It returns the largest integral value less than or equal to x.
fmod It returns the floating point remainder of x divided by y.
frexp It breaks the floating point number x into its mantisa and an integer exponent of 2.
idexp It returns the result of multiplying x with 2 raised to the power of exponent.
log It returns the natural logarithm(base-e logarithm) of x.
log10 It returns the common logarithm(base 10 logarithm) of x.
modf It breaks a floating point number into an integral and a fractional part.
pow It returns base raised to the power of exponent(xy).
sin It returns the sine of a radian angle.
sinh It returns the hyperbolic sine of a radian angle.
sqrt It returns the square root of a number.
tan It returns the tangent of a radian angle.
tanh It returns the hyperbolic tangent of a radian angle.

Macros Defined in math.h Library

Macro Description
HUGE_VAL Some math.h functions returns this MACRO to represent very large value(greater than the range of floating point number) of the calculated result. If magnitude of the result is large enough to be represented as floating point number, then it sets errno to ERANGE and returns HUGE_VAL or its negation -HUGE_VAL.