aboutsummaryrefslogtreecommitdiffstats
path: root/src/algorithms
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-10 20:08:29 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-10 20:08:29 +0100
commitfd8fa69fa02d8a6c9fbff40088b4e66a711599de (patch)
tree719a5ed424e913ea2ca64bd7f40df531158a3e81 /src/algorithms
parentm (diff)
downloadalgorithms-and-data-structures-fd8fa69fa02d8a6c9fbff40088b4e66a711599de.tar.gz
algorithms-and-data-structures-fd8fa69fa02d8a6c9fbff40088b4e66a711599de.tar.bz2
algorithms-and-data-structures-fd8fa69fa02d8a6c9fbff40088b4e66a711599de.tar.xz
fix bit pattern
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/algorithms/bits/Bits.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/algorithms/bits/Bits.java b/src/algorithms/bits/Bits.java
index 4d5c944..5172254 100644
--- a/src/algorithms/bits/Bits.java
+++ b/src/algorithms/bits/Bits.java
@@ -275,15 +275,15 @@ public class Bits
public static £{T} ones_parallel(£{T} value)
{
£{T} rc = value;
- rc = (£{T})(((rc >> 1) & (£{T})0xAAAAAAAAAAAAAAAAL) + (rc & (£{T})0xAAAAAAAAAAAAAAAAL));
- rc = (£{T})(((rc >> 2) & (£{T})0xCCCCCCCCCCCCCCCCL) + (rc & (£{T})0xCCCCCCCCCCCCCCCCL));
- rc = (£{T})(((rc >> 4) & (£{T})0xF0F0F0F0F0F0F0F0L) + (rc & (£{T})0xF0F0F0F0F0F0F0F0L));
+ rc = (£{T})(((rc >> 1) & (£{T})0x5555555555555555L) + (rc & (£{T})0x5555555555555555L));
+ rc = (£{T})(((rc >> 2) & (£{T})0x3333333333333333L) + (rc & (£{T})0x3333333333333333L));
+ rc = (£{T})(((rc >> 4) & (£{T})0x0F0F0F0F0F0F0F0FL) + (rc & (£{T})0x0F0F0F0F0F0F0F0FL));
£>(( $S > 1 )) &&
- rc = (£{T})(((rc >> 8) & (£{T})0xFF00FF00FF00FF00L) + (rc & (£{T})0xFF00FF00FF00FF00L));
+ rc = (£{T})(((rc >> 8) & (£{T})0x00FF00FF00FF00FFL) + (rc & (£{T})0x00FF00FF00FF00FFL));
£>(( $S > 2 )) &&
- rc = (£{T})(((rc >> 16) & (£{T})0xFFFF0000FFFF0000L) + (rc & (£{T})0xFFFF0000FFFF0000L));
+ rc = (£{T})(((rc >> 16) & (£{T})0x0000FFFF0000FFFFL) + (rc & (£{T})0x0000FFFF0000FFFFL));
£>(( $S > 4 )) &&
- rc = (£{T})(((rc >> 32) & (£{T})0xFFFFFFFF00000000L) + (rc & (£{T})0xFFFFFFFF00000000L));
+ rc = (£{T})(((rc >> 32) & (£{T})0x00000000FFFFFFFFL) + (rc & (£{T})0x00000000FFFFFFFFL));
return rc;
}