diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-01-20 02:36:11 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-01-20 02:36:11 +0100 |
commit | 29f54e47b035b78f87d1f0db59db4e689e1bd140 (patch) | |
tree | 0349d8d01951375301889b347f3b1a2bbc1cb153 /src/algorithms/bits/Absolute.java | |
parent | m + add abs (diff) | |
download | algorithms-and-data-structures-29f54e47b035b78f87d1f0db59db4e689e1bd140.tar.gz algorithms-and-data-structures-29f54e47b035b78f87d1f0db59db4e689e1bd140.tar.bz2 algorithms-and-data-structures-29f54e47b035b78f87d1f0db59db4e689e1bd140.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/algorithms/bits/Absolute.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/algorithms/bits/Absolute.java b/src/algorithms/bits/Absolute.java index 2e694eb..b1c29f4 100644 --- a/src/algorithms/bits/Absolute.java +++ b/src/algorithms/bits/Absolute.java @@ -33,10 +33,9 @@ public class Absolute */ public static £{T} abs(£{T} value) { - £{T} mask;; - return (value ^ (mask = value >> £{S})) - mask; - /* Or alternatively: - * (v + (mask = value >> £{S})) ^ mask + £{T} mask; + return (£{T})((value ^ (mask = (£{T})(value >> £{S}))) - mask); + /* Or alternatively make the ^ into an +, and the - into a ^. */ } £>done |