Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Константа 255 выглядит подозрительно #2

Open
doloto opened this issue Sep 27, 2012 · 0 comments
Open

Comments

@doloto
Copy link

doloto commented Sep 27, 2012

Если имелся ввиду сдвиг на 8, то умножать следует на 256:
(gdb) p/x 0xbe * 255 + 0xef
$17 = 0xbe31
(gdb) p/x 0xbe * 256 + 0xef
$18 = 0xbeef

byte URMSerial::processDistance(int& value)
{
....
// 1x16bit value wrapped over two bytes
// HighByte must be multiplied by 255 to represent the correct byte
// Both are added together to calculate the value in Centimeters (I believe)
value = serialData[HighByte]*255+serialData[LowByte];
return DISTANCE;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant