C++ Math less()30 Aug 2024 | 2 min read The less() function determines whether the value of first argument is less than the value of second argument. If first argument is less than the second argument then it returns 1 otherwise 0. Note: If one or both the arguments are NAN, then the function returns false(0).SyntaxConsider two numbers 'x' and 'y'. Syntax would be: Parameter(x,y): The values which we want to compare. Return value
Example 1Let's see a simple example when both x and y are of same type. Output: Values of x and y are : 1.2,1.3 isless(x,y) : 1 In this example, isless() function determines that the value of x is less than y. Therefore, it returns 1. Example 2Let's see a simple example when both x and y are of different type. Output: Values of x and y are : 7.2,5 isless(x,y) :0 In this example, isless() function determines that the value of x is not less than y. Therefore, it returns 0. Example 3Let's see a simple example when the value of x is nan. Output: Values of x and y are : nan,5.67 isless(x,y) : 0 In this example, value of x is nan. Therefore, the function returns 0. Next TopicC++ Math Functions |
C++ Math isnan() The function checks whether the number is a Not a Number or not. If the number is NaN, it returns 1 otherwise 0. Note: The NaN is a non-representable value for floating point elements such as square root of negative number or the result of...
1 min read
C++ Math lrint() The function rounds off the given value using current rounding mode and returns the value of type long int. Syntax Suppose a number is 'x'. Syntax would be: long int lrint(data_type x); Parameter x: The value that can be float, double or long double. Return value It returns the...
2 min read
C++ Math after() The after() function represents the representable value in a specific direction. Suppose two numbers are 'from' and 'to'. Therefore, the after() function finds the value of 'from' in the direction of 'to'. Syntax float after( float from, float to); double after( double from, double to); long double...
2 min read
C++ Math logb() The function computes the logarithm of a given number, using FLT_RADX as base for the logarithm. Generally, FLT_RADX is equal to 2. Therefore, logb() is equivalent to log2(). Syntax Suppose a number is 'x'. Syntax would be: float logb(float x); double logb(double x); long double logb(long double x); double logb(integral x); Parameter x:...
2 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 fpclassify() The function returns the value of type int that matches one of the macro constants, depending on the value of x. value description FP_INFINITE Positive or negative infinity FP_NAN Not a Number FP_ZERO Value of zero. FP_SUBNORMAL Sub Normal value FP_NORMAL Normal value Syntax Suppose a number is x. Syntax would be: int fpclassify(float x); int fpclassify(double x); int fpclassify(long double...
1 min read
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
C++ Math sin() The function is used to find the sine of an angle given in radian. Syntax Consider a radian 'x'. Syntax would be: float sin(float x); float sin(double x); float sin(long double x); double sin(integral x); Note: If the value passed is an integer type, then it is cast to double. Parameter x:...
1 min read
C++ Math cbrt() This function is used to find the cube root of a given number. Consider a argument 'arg' : Cube root of a number : ∛arg Syntax Syntax would be : double cbrt(double arg); float cbrt(float arg); long double cbrt(long double arg); double cbrt(integral arg); Parameter arg : It is the value of float or...
1 min read
C++ Math remainder() The function finds the floating point remainder of numerator/denominator (rounded to the nearest integer value). Formulae of remainder : Remainder = numerator - (r*denominator) where, r = numerator/denominator and it is rounded to the nearest integral value. Syntax Consider a numerator 'n' and denominator 'd'. Syntax would be: return_type...
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