C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math signbit()The function checks whether the sign of a given number is negative or not. If the sign of a number is negative, it returns 1 otherwise 0. The signbit() function can also be applied to infinite, NAN and zero value. SyntaxSuppose a number is 'x'.Syntax would be: bool signbit(float x); bool signbit(double x); bool signbit(long double x); bool signbit(integral x); Parameterx: It is a floating point value. Return valueIt returns 1, if the value of x is negative otherwise 0(false). Example 1Let's see the simple example when the value of x is 9. #include Output: value of x is :9 signbit(x) : 0 In this example, signbit(x) function determines that the value of x is positive. Therefore, it returns 0. Example 2Let's see the simple example when the value of x is -2. #include Output: value of x is : -2 signbit(x) : 1 In this example, signbit(x) function determines that the value of x is negative. Therefore, it returns 1. Example 3Let's see the simple example when the value of x is infinite. #include Output: value of x is : inf signbit(x) : 0 In this example, signbit(x) function determines that the value of x is positive infinite. Therefore, it returns 0 value.
Next TopicC++ Math Functions
|