From 8623a0bf1fb2136a32c172ee48d2ff3274ca2cef Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 20 Jan 2014 07:06:30 +0100 Subject: 64-bit instructions for parity on byte MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/algorithms/bits/Bits.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/algorithms/bits/Bits.java b/src/algorithms/bits/Bits.java index 8625310..3101217 100644 --- a/src/algorithms/bits/Bits.java +++ b/src/algorithms/bits/Bits.java @@ -64,6 +64,17 @@ public class Bits private static byte[] PARITY_TABLE_256 = { £(parity-table 4 0) }; + /** + * Compute the parity of all bits in an integer, 64-bit multiply–modulus version + * + * @param value The interger + * @return The parity + */ + public static int parity_64bit(byte value) + { + return (int)(((value * 0x0101010101010101L) & 0x8040201008040201L) % 0x1FF) & 1; + } + £S=${T_S#*_} -- cgit v1.2.3-70-g09d2