nic
2011-05-12 09:57:29 +02:00
parent fd5a1c5b4b
commit e759a14909
2 changed files with 12 additions and 14 deletions
@@ -86,10 +86,8 @@ public class SensorUtils {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if ((crc & 0x1) != 0x0) { if ((crc & 0x1) != 0x0) {
// we have to do the OxFF mask because the right shift is // Using a 0xFF bit assures that 0-bits are introduced during the shift operation.
// supposed to shift in a 0 // Otherwise, implicit casts to signed int could shift in 1-bits if the signed bit is 1.
// as crc gets implicitly casted to a
// signed int by >> it may be filled with 1s
crc = (byte) (((crc & 0xFF) >> 1) ^ 0x8C); crc = (byte) (((crc & 0xFF) >> 1) ^ 0x8C);
} else { } else {
crc = (byte) ((crc & 0xFF) >> 1); crc = (byte) ((crc & 0xFF) >> 1);