W
wij
Hi:
What is the protable way to negate an arithmetic integer?
template<typename T>
T negate(T t) {
return -t; // <-- problem
}
On my Intel machines, taking negation like the above is not
right if t is std::numeric_limits<T>::min()
So the question may be reduced to: how to detect to throw an error.
Thank you.
IJ. Wang
What is the protable way to negate an arithmetic integer?
template<typename T>
T negate(T t) {
return -t; // <-- problem
}
On my Intel machines, taking negation like the above is not
right if t is std::numeric_limits<T>::min()
So the question may be reduced to: how to detect to throw an error.
Thank you.
IJ. Wang