Skip to content

Commit

Permalink
bitsratio: fix incorrect result when not on GNU/Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
XPhyro committed Aug 23, 2024
1 parent abd3afa commit 7c76910
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/c/util/math/bitsratio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ int main(int argc, char *argv[])
#if defined(__GNUC__) || defined(__clang__)
popcount += __builtin_popcount(c & 0xff);
#else
popcount += c & 0x01 + c & 0x02 + c & 0x04 + c & 0x08 + c & 0x10 + c & 0x20 + c &
0x40 + c & 0x80;
popcount += ((c & (1 << 0)) >> 0) + ((c & (1 << 1)) >> 1) + ((c & (1 << 2)) >> 2) +
((c & (1 << 3)) >> 3) + ((c & (1 << 4)) >> 4) + ((c & (1 << 5)) >> 5) +
((c & (1 << 6)) >> 6) + ((c & (1 << 7)) >> 7);
#endif
}
}
Expand Down

0 comments on commit 7c76910

Please sign in to comment.