signBit(i) provides a fast way to determine the value of the sign bit (as a bool) for integral and floating types.
More...
signBit(i) provides a fast way to determine the value of the sign bit (as a bool) for integral and floating types.
Note that this is significantly different than sign(x); be sure you know what you're doing if you use this method. signBit() refers to the underlying representation rather than the numerical value. For example, for floating types there are two zeroes, +0 and -0 which have opposite sign bits but the same sign (0). Also, unsigned types have sign() of 0 or 1, but they are considered here to have a sign bit of 0 always, since the stored high bit does not indicate a negative value.
Notes
- signBit() is overloaded for 'signed char' and 'unsigned char', but not for plain 'char' because we don't know whether to interpret the high bit as a sign in that case (because the C++ standard leaves it unspecified).
- complex and conjugate numbers do not have sign bits.
- negator<float> and negator<double> have the same sign bit as the underlying representation – it's up to you to realize that it is interpreted differently!
- See also
- sign()
◆ signBit() [1/14]
bool SimTK::signBit |
( |
unsigned char |
u | ) |
|
|
inline |
◆ signBit() [2/14]
bool SimTK::signBit |
( |
unsigned short |
u | ) |
|
|
inline |
◆ signBit() [3/14]
bool SimTK::signBit |
( |
unsigned int |
u | ) |
|
|
inline |
◆ signBit() [4/14]
bool SimTK::signBit |
( |
unsigned long |
u | ) |
|
|
inline |
◆ signBit() [5/14]
bool SimTK::signBit |
( |
unsigned long long |
u | ) |
|
|
inline |
◆ signBit() [6/14]
bool SimTK::signBit |
( |
signed char |
i | ) |
|
|
inline |
◆ signBit() [7/14]
bool SimTK::signBit |
( |
short |
i | ) |
|
|
inline |
◆ signBit() [8/14]
bool SimTK::signBit |
( |
int |
i | ) |
|
|
inline |
◆ signBit() [9/14]
bool SimTK::signBit |
( |
long long |
i | ) |
|
|
inline |
◆ signBit() [10/14]
bool SimTK::signBit |
( |
long |
i | ) |
|
|
inline |
◆ signBit() [11/14]
bool SimTK::signBit |
( |
const float & |
f | ) |
|
|
inline |
◆ signBit() [12/14]
bool SimTK::signBit |
( |
const double & |
d | ) |
|
|
inline |
◆ signBit() [13/14]
bool SimTK::signBit |
( |
const negator< float > & |
nf | ) |
|
|
inline |
◆ signBit() [14/14]
bool SimTK::signBit |
( |
const negator< double > & |
nd | ) |
|
|
inline |