Number in C++
Generally, while working with the numbers in C++, the use of primitive data types like long, short, float, int, etc. are used. These are basically the general math functions that are provided by the C++ programming and is the header file that is required to use these functions.
Here are the list of functions sorted according to their genre along with a brief description:
Nearest integer operations in C++
Method |
Description |
ceil(x) |
This function rounds up the value of x. |
floor(x) |
This function generally rounds down the value of x. |
round(x) |
This function generally rounds off the value of x. |
lround(x) |
This function is used to round off the value of x and cast to long integer. |
llround(x) |
This function is used to round off the value of x and cast that value to the long integer. |
fmod(n,d) |
This function is used to calculate the remainder of division n/d. |
trunc(x) |
This function is used to round off the value x towards zero. |
rint(x) |
This function is used to round off the value of x using rounding mode. |
lrint(x) |
This function is used to round off the value of x using rounding mode and cast to long integer. |
llrint(x) |
This function is used to round off the value x and cast to long long integer. |
nearbyint(x) |
This function is used to round off the value x to a nearby integral value. |
remainder(n,d) |
This function is used to calculate the remainder of n/d. |
remquo() |
This function is used to calculate the remainder and quotient both. |
Power functions in C++
Method |
Description |
pow(x,y) |
This function generally computes x raised to the power y. |
sqrt(x) |
This function generally calculates the square root of x. |
cbrt(x) |
This function generally calculates the cube root of x. |
hypot(x,y) |
This function is used to find the hypotenuse of a right angled triangle. |
Trignometric Functions in C++
Method |
Description |
cos(x) |
This function in C++ is used to compute the cosine of x. |
sin(x) |
This function in C++ is used to compute the sine of x. |
tan(x) |
This function in C++ is used to compute the tangent of x. |
acos(x) |
This function in C++ is used to find the inverse cosine of x. |
asin(x) |
This function in C++ is used to find the inverse sine of x. |
atan(x) |
This function in C++ is used to find the inverse tangent of x. |
atan2(x,y |
This function in C++ is used to find the inverse tangent of a coordinate x and y. |
Hyperbolic Functions in C++
Method |
Description |
cosh(x) |
This function in C++ is used to compute the hyperbolic cosine of x. |
sinh(x) |
This function in C++ is used to compute the hyperbolic sine of x. |
tanh(x) |
This function in C++ is used to compute the hyperbolic tangent of x. |
acosh(x) |
This function in C++ is used to find the arc hyperbolic cosine of x. |
asinh(x) |
This function in C++ is used to find the arc hyperbolic sine of x. |
atanh(x) |
This function in C++ is used to find the arc hyperbolic tangent of x. |
Exponential Functions in C++
Method |
Description |
exp(x) |
This function in C++ is used to compute the exponential e raised to the power x. |
frexp(value_type x,int* exp) |
This function in C++ is used to break a number into significand and 2 raised to the power exponent. |
Idexp(float x, int e) |
This function in C++ is used to compute the product of x and 2 raised to the power e. |
log(x) |
This function in C++ is used to compute the natural logarithm of x. |
log10(x) |
This function in C++ is used to compute the common logarithm of x. |
modf() |
This function in C++ is used to break a number into an integer and fractional part. |
exp2(x) |
This function in C++ is used to compute the base 2 exponential of x. |
expm1(x) |
This function in C++ is used to compute the exponential raised to the power x minus one. |
log1p(x) |
This function in C++ is used to compute the natural logarithm of x plus one. |
log2(x) |
This function in C++ is used to compute the base 2 logarithm of x. |
logb(x) |
This function in C++ is used to compute the logarithm of x. |
scalbn( x, n) |
This function in C++ is used to compute the product of x and FLT_RADX raised to the power n. |
scalbln( x, n) |
This function in C++ is used to compute the product of x and FLT_RADX raised to the power n. |
ilogb(x) |
This function in C++ is used to return the exponent part of x. |
Floating point manipulation functions in C++
Method |
Description |
copysign(x,y) |
This function in C++ is used to return the magnitude of x with the sign of y. |
nextafter(x,y) |
This function is generally used to represent the next representable value of x in the direction of y. |
nexttoward(x,y) |
This function is generally used to represent the next representable value of x in the direction of y. |
Maximum,Minimum and Difference functions in C++
Method |
Description |
fdim(x,y) |
This function is used to calculate the positive difference between x and y. |
fmax(x,y) |
This function returns the larger number among two numbers x and y. |
fmin() |
This function returns the smaller number among two numbers x and y . |