Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Unified Diff: base/numerics/safe_conversions_impl.h

Issue 2574443002: Make base/numerics abs match runtime libraries (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/numerics/safe_conversions_impl.h
diff --git a/base/numerics/safe_conversions_impl.h b/base/numerics/safe_conversions_impl.h
index 33d86bcedb250588d6df3fa21196501edb781ca7..c4d96365ff4d71d96ceffa739fc02dccff868c3f 100644
--- a/base/numerics/safe_conversions_impl.h
+++ b/base/numerics/safe_conversions_impl.h
@@ -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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698