Problem Detail: I’m adapting an algorithm for calculating a CRC 16-bit CCITT (XModem) value from an ASCII input. I’ve found some code here. I’m using the function the poster has in his question, but I’ve noticed at the bottom he does this:
calcrc = crc And &HFFFF
What’s the purpose of applying such a bit mask that is all 1s to a value? Doesn’t that just return the value again?
Asked By : rory.ap
Answered By : w00d
The reason is crc that it’s calculating is defined to be a 16-bit value, the And &HFFFF will truncate the most significant bit outside the 16-bit range if there is any overflow during the calculation.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/39809