I have searched the manual and this forum for the two’s complement command. I guess I can't find it or there is none.
So will this do it?
Or is there a way I have not found?Code:CHKSUM = (CHKSUM REV7)+1
I have searched the manual and this forum for the two’s complement command. I guess I can't find it or there is none.
So will this do it?
Or is there a way I have not found?Code:CHKSUM = (CHKSUM REV7)+1
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
There are a couple ways to work with 2's compliment numbers.
"2's compliment" is simply a way to store positive and negative numbers.
You can can change a number to a positive value when it's either positive or negative using the ABS (Absolute Value) function.
PosValue = ABS MyValue
Or, a value can be inverted ... made positive if it's negative, or negative if it's positive using the negative sign.
InvValue = -(MyValue)
That is the same as complimenting the bits and adding 1.
Which can also be done with the bitwise NOT operator (+1).
InvValue = ~(MyValue) + 1
DT
Ok, thanks Darrel, I will use the last 1. It just looks cool!
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Bookmarks