This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t MokaFramer::crc32Step(uint32_t crc, uint8_t byte) { | |
crc ^= byte; | |
for (uint32_t j = 0; j < 8; j++) { | |
uint32_t mask = (uint32_t) -(crc & 1U); | |
crc = (crc >> 1) ^ (0xedb88320U & mask); | |
} | |
return crc; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crc_step(crc : UInt32, byte : UInt8) | |
crc ^= byte | |
[0..7].each do |j| | |
mask = (crc & 1_u32) | |
mask = -1 * mask | |
crc = (crc >> 1_u32) ^ (0xedb88320_u32 & mask) | |
end | |
crc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment