fix parity (#4476)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
Samuel Sieb 2023-02-22 15:40:20 -08:00 committed by GitHub
parent 98b3d294aa
commit 8e1430243e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,8 +38,8 @@ void Wiegand::setup() {
bool check_eparity(uint64_t value, int start, int length) {
int parity = 0;
uint64_t mask = 1LL << start;
for (int i = 0; i <= length; i++, mask <<= 1) {
if (value & i)
for (int i = 0; i < length; i++, mask <<= 1) {
if (value & mask)
parity++;
}
return !(parity & 1);
@ -48,8 +48,8 @@ bool check_eparity(uint64_t value, int start, int length) {
bool check_oparity(uint64_t value, int start, int length) {
int parity = 0;
uint64_t mask = 1LL << start;
for (int i = 0; i <= length; i++, mask <<= 1) {
if (value & i)
for (int i = 0; i < length; i++, mask <<= 1) {
if (value & mask)
parity++;
}
return parity & 1;