From d2de1d9a704fc4b23e9a9fb8d610620d6d4752c1 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 27 Jul 2018 17:30:05 -0400 Subject: fix bit operation bugs in Bits --- include/salticidae/stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h index 267d294..50a7f70 100644 --- a/include/salticidae/stream.h +++ b/include/salticidae/stream.h @@ -360,13 +360,13 @@ class _Bits { void set(uint32_t idx) { auto i = idx >> shift_per_datum; auto pos = idx & (bit_per_datum - 1); - data[i] ^= ((data[i] >> pos) ^ 1) << pos; + data[i] ^= (((data[i] >> pos) & 1) ^ 1) << pos; } void unset(uint32_t idx) { auto i = idx >> shift_per_datum; auto pos = idx & (bit_per_datum - 1); - data[i] ^= (data[i] >> pos) << pos; + data[i] ^= ((data[i] >> pos) & 1) << pos; } void flip(uint32_t idx) { -- cgit v1.2.3-70-g09d2