Android Question Help with porting checksum equation to B4A

Beja

Expert
Licensed User
Longtime User
Hello all,
I have the following two equations that I want to use in B4A project.. Any help appreciated

1- checksum_high - ((speed_1 + speed_2 + 0) >> 8) & 0xFF
2- checksum_low - (speed_1 + speed_2 + 0) & 0xFF

Best
 

sorex

Expert
Licensed User
Longtime User
probably

bit.and(checksum_high - ((speed_1 + speed_2 + 0)/256),0xff)
bit.and(checksum_low - (speed_1 + speed_2 + 0),0xff)

or if you don't like the bit operations this might work when it's stored in an int

(checksum_high - ((speed_1 + speed_2 + 0)/256)) mod 256
(checksum_low - (speed_1 + speed_2 + 0) mod 256
 
Upvote 0
Top