macro/function
<cmath> <ctgmath>
signbit functionbool signbit (float x);bool signbit (double x);bool signbit (long double x);
Sign bit
Returns whether the sign of x is negative.This can be also applied to infinites, NaNs and zeroes (if zero is unsigned, it is considered positive).
In C, this is implemented as a macro that returns an int
value. The type of x shall be float
, double
or long double
.
In C++, it is implemented with function overloads for each
floating-point type, each returning a
bool
value.
true
) if the sign of x is negative; and zero (false
) otherwise.
1
2
3
4
5
6
7
8
9
10
11
12
/* signbit example */
#include <stdio.h> /* printf */
#include <math.h> /* signbit, sqrt */
int main()
{
printf ("signbit(0.0) : %d\n",signbit(0.0));
printf ("signbit(1.0/0.0) : %d\n",signbit(1.0/0.0));
printf ("signbit(-1.0/0.0) : %d\n",signbit(-1.0/0.0));
printf ("signbit(sqrt(-1.0)): %d\n",signbit(sqrt(-1.0)));
return 0;
}
signbit(0.0) : 0 signbit(1.0/0.0) : 0 signbit(-1.0/0.0) : 1 signbit(sqrt(-1.0): 1
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4