C++ Math round()30 Aug 2024 | 1 min read This function is used to round off the given value which can be either float or double. For example: SyntaxSuppose a number is 'x'. Syntax would be: Parameterx : The value which can be either float or double. Return valueIt returns the rounded value of x. The return type of the value can be float, double or long double. Example 1Let's see a simple example when the value of x is positive Output: The value of x is : 8.3 Rounded value of x is : 8 Example 2Let's see a simple example when the value of x is negative. Output: The value of x is : -9.9 Rounded value of x is : -10 Next TopicC++ Math Functions |
math scalbln() function
C++ Math scalbln() The function computes the product of a given number and FLT_RADX raised to the power of exponent. Suppose a number is 'x' and exponent is 'n': scalbn(x,n) = x * ( FLT_RADX)n Syntax float scalbln(float x, long int n); double scalbln(double x, long int n); long double scalbln(long double x,...
1 min read
math fdim() function
C++ Math fdim() The function calculates the positive difference between two numbers. Conditions : Consider two numbers 'x' and 'y' : If(x>y): It returns (x-y); If(y>x): It returns zero. Syntax float fdim(float x, float y); double fdim(double x, double y); long double fdim(long double x, long double y); promoted fdim(Arithmetic x, Arithmetic y); Note: If any argument...
2 min read
math acos() function
C++ Math acos() This function computes the inverse cosine of a number in radian. acos(x) = cos -1x Syntax Suppose a number is x. Syntax would be: float acos(float x); double acos(double x); long double acos(long double x); double acos(integral x); Note: If the value passed is an integer type, then it is cast to...
2 min read
math exp2() function
C++ Math exp2() The function computes the base - 2 exponential function of a given number. Suppose a number is 'x': exp2(x) = 2<sup>x</sup> Syntax float exp2(float x); double exp2(double x); long double exp2(long double x); double exp2(integral x); Parameter x: It is the value of the exponent. Return value It returns, 2 raised to the power x....
1 min read
math sqrt() function
sqrt() in C++ In C++, the sqrt() function is used to calculate the square root of a non-negative value. It belongs to the library and produces a double-type result. This function is accessed through the header. It is specified in the header file. It calculates the positive...
4 min read
math exp() function
C++ Math exp() The function computes the exponential e raised to the power given number. Suppose a number is x: exp() = ex Syntax Consider a number 'x'. Syntax would be: float exp(float x); double exp(double x); long double exp(long double x); double exp(integral x); Parameter x: The value whose exponential value is to be calculated. Return value It...
1 min read
math nearbyint() function
C++ Math nearbyint() The function rounds off the given value to a nearby integral value by using the current rounding method. The current rounding method is described by fegetround. Syntax Suppose a number is 'x'. Syntax would be: return_type nearbyint(data_type x); Note: The return_type can be float, double or long...
1 min read
math modf() function
C++ Math modf() This function is used to divide a number into integral and fractional part. For example : 2.16 = 2 + 16 Syntax Suppose a number is 'x' and 'ptr' is the pointer to an integral part. float modf(float x, float* ptr); double modf(double x, double* ptr); long double modf(long double x,...
2 min read
math cos() function
C++ Math cos() The function is used to find the cosine of an angle expressed in terms of radian. Syntax Consider a radian 'x'. Syntax would be: float cos(float x); float cos(double x); float cos(long double x); double cos(integral x); Note: If the value passed is an integer type, then it is cast to...
1 min read
math isgreater() function
C++ Math isgreater() The isgreater() function determines whether the value of first argument given in function is greater than the value of second argument. If the first number is greater, it returns 1 otherwise 0. Note: If one or both the arguments of a function are NAN then...
2 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India