
27 Feb
2008
27 Feb
'08
4:31 p.m.
Johan RĂ¥de wrote:
There is one other useful function worth having IMO:
template <class T> int sign(T x);
returns 0 (x is zero), +1 (x is > 0) or -1 (x is < 0). This is trivial to implement (lot's of old C code - for example the Numerical Recipies stuff - implement this as a helper macro), and there's an undocumented version currently in Boost.Math. Is this worth integrating with Johan's code? I've found it quite useful in Boost.Math from time to time.
What should this function return for a NaN?
In any of the use cases I have for that function, it would be an error to be trying to handle NaN's. So it's a domain error I guess. John.