
2 Aug
2006
2 Aug
'06
3:53 p.m.
Paul A Bristow wrote:
Does anyone have a ***portable*** version of macro signbit (C99)
Not quite, but I recently added a rather brain dead version to the Math-Toolkit code, just a: template <class T> int signbit(const T& v) { return v < 0 ? 1 : 0; } To be honest that's not very useful :-( What I do find more useful is: template <class T> int sign(const T& v) { return v < 0 ? -1 : 1; } which is invaluable when you need to compare the sign of two (or more) numbers but are concerned about numeric overflow/underflow in the usual a*b < 0 trick. John.