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()
bool SimTK::signBit |
( |
unsigned char |
u | ) |
|
|
inline |
bool SimTK::signBit |
( |
unsigned short |
u | ) |
|
|
inline |
bool SimTK::signBit |
( |
unsigned int |
u | ) |
|
|
inline |
bool SimTK::signBit |
( |
unsigned long |
u | ) |
|
|
inline |
bool SimTK::signBit |
( |
unsigned long long |
u | ) |
|
|
inline |
bool SimTK::signBit |
( |
signed char |
i | ) |
|
|
inline |
bool SimTK::signBit |
( |
short |
i | ) |
|
|
inline |
bool SimTK::signBit |
( |
int |
i | ) |
|
|
inline |
bool SimTK::signBit |
( |
long long |
i | ) |
|
|
inline |
bool SimTK::signBit |
( |
long |
i | ) |
|
|
inline |
bool SimTK::signBit |
( |
const float & |
f | ) |
|
|
inline |
bool SimTK::signBit |
( |
const double & |
d | ) |
|
|
inline |
bool SimTK::signBit |
( |
const negator< float > & |
nf | ) |
|
|
inline |
bool SimTK::signBit |
( |
const negator< double > & |
nd | ) |
|
|
inline |