Skip to content

Commit 68bbac0

Browse files
committed
Fix precedence bug in HABSOps (cast before mod)
1 parent 1ff4193 commit 68bbac0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/src/main/java/org/neo4j/gds/core/utils/paged/HugeAtomicBitSetOps.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class HugeAtomicBitSetOps {
3131
static boolean get(HugeAtomicLongArray bits, long numBits, long index) {
3232
assert (index < numBits);
3333
long wordIndex = index / NUM_BITS;
34-
int bitIndex = (int) index % NUM_BITS;
34+
int bitIndex = (int) (index % NUM_BITS);
3535
long bitmask = 1L << bitIndex;
3636
return (bits.get(wordIndex) & bitmask) != 0;
3737
}
@@ -43,7 +43,7 @@ static void set(HugeAtomicLongArray bits, long numBits, long index) {
4343
assert (index < numBits);
4444

4545
long wordIndex = index / NUM_BITS;
46-
int bitIndex = (int) index % NUM_BITS;
46+
int bitIndex = (int) (index % NUM_BITS);
4747
long bitmask = 1L << bitIndex;
4848

4949
long oldWord = bits.get(wordIndex);
@@ -115,7 +115,7 @@ static boolean getAndSet(HugeAtomicLongArray bits, long numBits, long index) {
115115
assert (index < numBits);
116116

117117
long wordIndex = index / NUM_BITS;
118-
int bitIndex = (int) index % NUM_BITS;
118+
int bitIndex = (int) (index % NUM_BITS);
119119
long bitmask = 1L << bitIndex;
120120

121121
long oldWord = bits.get(wordIndex);
@@ -142,7 +142,7 @@ static void flip(HugeAtomicLongArray bits, long numBits, long index) {
142142
assert (index < numBits);
143143

144144
long wordIndex = index / NUM_BITS;
145-
int bitIndex = (int) index % NUM_BITS;
145+
int bitIndex = (int) (index % NUM_BITS);
146146
long bitmask = 1L << bitIndex;
147147

148148
long oldWord = bits.get(wordIndex);
@@ -242,7 +242,7 @@ static void clear(HugeAtomicLongArray bits, long numBits, long index) {
242242
assert (index < numBits);
243243

244244
long wordIndex = index / NUM_BITS;
245-
int bitIndex = (int) index % NUM_BITS;
245+
int bitIndex = (int) (index % NUM_BITS);
246246
long bitmask = ~(1L << bitIndex);
247247

248248
long oldWord = bits.get(wordIndex);

0 commit comments

Comments
 (0)