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 |
C++ Math log2() The function computes the base 2 logarithm of a given number. Suppose a number is 'x': log2(x) = log2x; Syntax float log2(float x); double log2(double x); long double log2(long double x); double log2(integral x); Note: The return_type can be float, double or long double. Parameter x: The value whose logarithm is to be...
2 min read
C++ Math ceil() It rounds the value to the nearest integer which is not less than the given value. For example : ceil(8.1)=9.0; ceil(-8.8)=-8.0; Syntax Suppose a number is 'x'. Syntax would be: double ceil(double x); Parameter x : It is the value that rounds to the nearest integer. Return value It returns the smallest integer value...
1 min read
C++ Math fmin() The function returns the minimum value between two numbers. Conditions: Consider two numbers 'x' and 'y'. If(x: It returns x. If(x>y): It returns y. If(x=nan): It returns y. If(y=nan):It returns x. Syntax float fmin(float x, float y); double fmin(double x, double y); long double fmin(long double x, long double y); promoted fmin(Arithmetic x, Arithmetic y); Note:...
1 min read
C++ Math isunordered() The isunordered() function checks whether the value of first argument can be meaningfully compared with the second argument. If the first argument cannot be meaningfully compared with the second argument (i.e one or both are NAN), it return 1 otherwise 0. Syntax Consider two numbers 'x'...
1 min read
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
C++ Math atan2() The function finds the inverse tangent of a coordinate. Suppose the coordinate is (x,y): atan2(y,x) = tan-1(y/x); Syntax Suppose the coordinate is (x,y). Syntax would be: float atan2(float y, float x); double atan2(double y, double x); long double atan2(long double y, long double x); Promoted atan2(Arithmetic1 y, Arithmetic x ); Parameter y: It represents...
2 min read
C++ Math isnormal() The function determines that whether the given number is normal or not. If the number is normal, it returns 1 otherwise 0. Syntax Suppose a number is 'x'. Syntax would be: bool isnormal(float x); bool isnormal(double x); bool isnormal(long double x); bool isnormal(integral x); Parameter x: It...
1 min read
C++ Vector hypot() This function finds the square root of the sum of the squares of two numbers. It stands for hypotenuse, is used to find the hypotenuse of a right angled triangle. Consider three numbers x,y and z : hypotenuse of a right angle triangle = √x2+y2 distance from...
1 min read
C++ Math fma() The function computes the expression x*y+z without losing its precision in any intermediate result. Suppose numbers are x,y and z: fma(x,y,z) = x*y+z; Syntax float fma(float x, float y, float z); double fma(double x, double y, double z); long double fma(long double x, long double y, long double z); double fma(type1...
1 min read
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
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