Mathematical Functions

What are Mathematical Functions in C++?

Explanation

Standard Function Library has a numerous set of Mathematical Functions. The header file required for mathematical functions are"<cmath>" or "<math.h>".

There are three macros used by Mathematical functions they are HUGE_VAL, EDOM, ERANGE that are declared using the header "<cerrno>" or the file "errno.h". In a function routine a large result or an overflow occurs it returns "HUGE_VAL" and the "errno" is set to "ERANGE" for a range error. When an underflow happens the function returns zero and sets the "errno" to "ERANGE". All the angles returned by cmath and math.h functions are in radians.

Following table lists few Mathematical functions of C++ Standard function Library. This function operated on "double" datatype, but now C++ also supports "float" and "long double".
Name Description
acos Returns the arc cosine value.
atan Returns the arc tangent value.
cos Returns the cosine value.
cosh Returns the hyperolic cosine value.
atan2 Returns the arc tangent of y/x.
ceil Returns the smallest integer not less than the given value.
exp Returns the natural logarithm base "e" raised to the argument value.
fabs Returns the absolute value of the num.
floor Returns the largest Integer not greater than the given value.
fmod Returns the remainder of two values.
frexp Converts a number into a mantissa between the range .5 to less than 1.
ldexp Returns the value of the number * 2 to the power of "exp"
log Returns the natural algorithm for the given value.
log10 Returns the base 10 algorithm for a number.
modf Segregates the number into its integer and fractional parts.
pow Returns the exponential value.
sin() Return the sine value for the argument.
sinh()sinh Return the hyperbolic sine value for the argument.
sqrt() Returns the square root of the argument.
tanh() Return the hyperbolic tangent value for the argument.
tan() Return the tangent value for the argument.


Following table lists few Mathematical functions of C++ Standard function Library. This function operated on "double" datatype, but now C++ also supports "float" and "long double".

C++ Tutorial


Ask Questions

Ask Question