diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/algorithms/bits/Absolute.java | 7 | ||||
-rw-r--r-- | src/algorithms/bits/Signum.java | 2 |
2 files changed, 4 insertions, 5 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 diff --git a/src/algorithms/bits/Signum.java b/src/algorithms/bits/Signum.java index 3744be7..07ddddf 100644 --- a/src/algorithms/bits/Signum.java +++ b/src/algorithms/bits/Signum.java @@ -92,7 +92,7 @@ public class Signum */ public static boolean haveOpposite(£{T} a, £{T} b) { - return (x ^ y) < 0; + return (a ^ b) < 0; } £>done } |