Commit e2d3dd95 authored by jschuh's avatar jschuh Committed by Commit bot

Make base/numerics abs match runtime libraries

This is the version all the runtime libraries seem to
use. So, I'm matching it on the assumption the
compiler may do something smarter if appropriate.

TBR=scottmg
NOTRY=true

Review-Url: https://codereview.chromium.org/2574443002
Cr-Commit-Position: refs/heads/master@{#437996}
parent de6c362b
......@@ -54,7 +54,7 @@ constexpr T BinaryComplement(T x) {
template <typename T>
constexpr T SafeUnsignedAbsImpl(T value, T sign_mask) {
static_assert(!std::is_signed<T>::value, "Types must be unsigned.");
return (value + sign_mask) ^ sign_mask;
return (value ^ sign_mask) - sign_mask;
}
template <typename T,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment