C math.h header

In C programming the <math.h> defined various functions that can be utilized to carry out various mathematical operations.It also define some macros,types and error types.The macros are used to represent some specific values like infinity or NaN(Not a Number).The types defined are macros for the floating point type and note the same macro may signify different floating point type depending on your compiler.The error types


HUGE_VALRepresent a huge value
INFINITYA macro that represent an infinity.
NANA macro to represent a ‘NaN’ value.


float_tA float type but it can vary.
double_tA double type but it can vary.

Error types

Domain errorAn error that occurs if the supplied argument is inconsistent for which the function is defined.
Range errorIf the function’s result cannot be outputted as double value or within any of the specified type.

All the functions defined in this header is shown below.


Function name and
Function definition

Classification function
boolfpclassify(double x)Returns value corresponding to the argument type.
boolisfinite(double x)Determines if the argument is finite.
boolisinf(double x)Determines if the argument is infinity
boolisnan(double x)Determines if the argument is nan
boolisnormal(double x)Determines if the argument is normal
boolsignbit(double x)Determine the sign of the argument

Trigonometric function
doubleacos(double arg)Returns arc cosine of arg
doubleasin(double arg)Return the arc sine of arg
doubleatan(double arg)Returns the arc tangent of arg
doubleatan2(double arg1,double arg2)Returns the arc tangent of arg1/arg2
doublecos(double arg)Returns the cosine of the arg
doublesin(double arg1)Returns the sine of arg
doubletan(double arg)Returns tangent of arg

Hyperbolic function
doubleacosh(double arg)Returns inverse hyperbolic cosine of arg
doubleasinh(double arg)Returns the inverse hyperbolic sine of arg
doubleatanh(double arg)Returns the inverse hyperbolic tangent of arg
doublecosh(double arg)Returns the hyperbolic cosine of arg
doublesinh(double arg)Returns the hyperbolic sine of arg
doubletanh(double arg)Returns hyperbolic tangent of arg

Exponential and logarithmic
doubleexp(double arg)Returns the logarithm base e raise to the power arg
doubleexp2(double arg)Returns base-2 exponential of arg
doubleexpm1(double arg)Returns base-e exponential of arg minus 1
doublefrexp(double arg ,int *exp)Decomposes arg into mantissa*2 ^ e and returns the mantissa
intilogb(double arg)Returns exponent of arg as a signed int value
doubleldexp(double arg,int exp)Returns arg*2 ^ exp
doublelog(double arg)Returns the logarithm of arg
doublelog10(double arg)Returns the base 10 logarithm of arg
doublelog1p(double arg)Returns base-e logarithm of 1+arg
doublelog2(double arg)Retuns base-2 logarithm of arg
intlogb(double arg)Returns exponent of arg as signed int
doublemodf(double arg,double* ptr)Decompose arg into intger and fractional
doublescalbln(double arg1,long pow)
scalbn(double arg , int pow)
Returns x*FLT_RADIXpow

Power and absolute value
doublecbrt(double arg)Returns the real cube root of arg
doublefabs(double arg)
abs(double arg)
Returns absolute value of arg
doublehypot(double arg1,double arg2)Returns square root of the sum of square of arg1 and arg2
doublepow(double arg1,double arg2)Returns arg1 ^ arg2
doublesqrt(double arg)Returns square root of arg

Error and gamma
doubleerf(double arg)Returns error function of arg
doubleerfc(double arg)Returns complementary error function of arg
doublelgamma(double arg)Returns natural logarithm of the absolute value of arg
doubletgamma(double arg)Computes gamma function of arg

Nearest integer
doubleceil(double arg)Returns the smallest integer not less than arg
doublefloor(double arg)Returns largest integer representable by arg
doublenearbyint(double arg)Returns rounded integer value
doublerint(double arg)Returns rounded integer value
doublellrint(double arg)
lrint(double arg)
return nearest integer value after rounding off
doubleround(double arg)Round arg to nearest integer
doublellround(double arg)
lround(double arg)
Round arg to nearest integer
doubletrunc(double arg)Truncate arg to integer component

Remainder function
doublefmod(double arg1,double arg2)Returns the remainder of arg1/arg2
doubleremainder(double arg1,double arg2)Computes the remainder of arg1/arg2
doubleremquo(double arg, double arg2,int *quo)(C++11)Returns remainder

Manipulation function
doublecopysign(double arg1,double arg2)Returns arg1 with the sign of arg2
doublenan(const char* arg)Returns quite nan
doublenextafter(double arg1,double arg2)Returns representable value after arg1 toward arg2
doublenexttoward(double arg1,long double arg2)Returns representable value after arg1 toward arg2

Maximum,minimum and positive difference
doublefdim(double arg1,double arg2)Returns (arg1 – arg2) if arg1>arg2 ,else +0
doublefmax(double arg1,double arg2)Returns maximum numeric value of the arguments
doublefmin(double arg1,double arg2)Returns the minimum numeric value of arguments

Floating multiply
doublefma(double arg1 ,double arg2 ,double arg3)Returns (arg1*arg2)+arg3

intisgreater(double arg1 , double arg2)Determine if arg1 is greater than arg2
intisgreaterequal(double arg1 , double arg2)Determine if arg1 is greater or equal to arg2
intisless(double arg1,double arg2)Determine if arg1 is less than arg2
intislessequal(double arg1,double arg2)Determine if arg1 is less than or equla to arg2
intislessgreater(double arg1,double arg2)Determine if arg1 is less than or greater than arg2
intisunordered(double arg1,double arg2)Determine the arguments are undordered