Skip to content

Commit db801a0

Browse files
committed
hamming Distance loop change condinition and distance min
1 parent bf7a930 commit db801a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

decoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ unsigned __int8 decoder::hammingDistance(unsigned __int8 x, unsigned __int8 y) {
7878
__int8 distance = 0;
7979
unsigned __int8 xorResult = x ^ y; // XOR of the two unsigned __int8
8080
// Count the number of set bits in the XOR result
81-
while (xorResult) {
81+
while (xorResult > 0) {
8282
distance += xorResult & 1;
8383
xorResult >>= 1;
8484
}
85-
return distance;
85+
return distance - 1;
8686
}
8787

8888
void decoder::logLevel() {

0 commit comments

Comments
 (0)