3 ms·
I recalled seeing a nicer sign() or sgn() function. Here it is: template <typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); }
by ape4 6y ago
I recalled seeing a nicer sign() or sgn() function. Here it is:
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
Not mine, from here
https://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c https://stackoverflow.com/questions/1903954/is-there-a-stand...