Click here to Skip to main content
15,906,218 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Tree View Pin
Tim Ranker31-Jul-03 3:39
Tim Ranker31-Jul-03 3:39 
GeneralRe: MFC Tree View Pin
rahulmsaxena31-Jul-03 3:51
rahulmsaxena31-Jul-03 3:51 
GeneralRe: MFC Tree View Pin
Tim Ranker31-Jul-03 4:54
Tim Ranker31-Jul-03 4:54 
GeneralRe: MFC Tree View Pin
rahulmsaxena31-Jul-03 9:20
rahulmsaxena31-Jul-03 9:20 
GeneralRe: MFC Tree View Pin
Tim Ranker31-Jul-03 10:16
Tim Ranker31-Jul-03 10:16 
GeneralHowto: get a Two's Complement Checksum Pin
DudleyDoorite31-Jul-03 2:43
DudleyDoorite31-Jul-03 2:43 
GeneralRe: Howto: get a Two's Complement Checksum Pin
Ryan Binns31-Jul-03 3:19
Ryan Binns31-Jul-03 3:19 
GeneralRe: Howto: get a Two's Complement Checksum Pin
Tim Ranker31-Jul-03 3:31
Tim Ranker31-Jul-03 3:31 
Hello Dudley,

It is perfectly acceptable to have the sum of all the bytes "roll over" beyoung the maximum value of the data type you are using, 8 bit or byte. If your running checksum is a byte something like the following will probably happen:

Lets say you want to add the following three bytes 127, 63, and 98. The running 8 bit checksum and 16 bit check sum would be the following.

                Checksum Total
Byte         (8 bit)       (16 bit)
127(0x7F)   127(0x7F)     127(0x7F)
63(0x3F)    190(0xBE)     190(0xBE)
98(0x62)     32(0x20)     288(0x0120)

The 8 bit check sum is just the 8 LSB or the 16 bit checksum.
In your implementation, you can just use a BYTE for your checksum and add all the data bytes, or you can use a larger data type like an int for your checksum and your 8 bit checksum would be the 8 Least Significant Bits.

Don't forget that after you have added all the bytes you need to do the 2's complement.
Invert all the bits and add one.

(C language)
checksum = ~checksum + 1;

The final checksum for the above example would be:
224(0xE0)

When you add the sum of all the bytes and the final checksum together, you should get zero.
32(0x20) + 224(0xE0) = 256(0x100);
But 256 is really 0 for a 8 bit data type (0x00);

Hope this helps.
Tim
GeneralRe: Howto: get a Two's Complement Checksum Pin
DudleyDoorite31-Jul-03 3:43
DudleyDoorite31-Jul-03 3:43 
GeneralExtracting Audio from AVI Pin
Anonymous31-Jul-03 2:22
Anonymous31-Jul-03 2:22 
GeneralRe: Extracting Audio from AVI Pin
Jim Crafton31-Jul-03 8:07
Jim Crafton31-Jul-03 8:07 
Generallaser pointer interaction Pin
sleep223131-Jul-03 1:34
sleep223131-Jul-03 1:34 
GeneralRe: laser pointer interaction Pin
Alexander M.,31-Jul-03 10:40
Alexander M.,31-Jul-03 10:40 
General_beginthread newbie question Pin
tareqsiraj31-Jul-03 1:24
tareqsiraj31-Jul-03 1:24 
GeneralRe: _beginthread newbie question Pin
Rage31-Jul-03 1:32
professionalRage31-Jul-03 1:32 
GeneralRe: _beginthread newbie question Pin
Renjith Ramachandran31-Jul-03 1:42
Renjith Ramachandran31-Jul-03 1:42 
GeneralRe: _beginthread newbie question Pin
tareqsiraj31-Jul-03 1:50
tareqsiraj31-Jul-03 1:50 
GeneralRe: _beginthread newbie question Pin
Jim Crafton31-Jul-03 8:11
Jim Crafton31-Jul-03 8:11 
GeneralRe: _beginthread newbie question Pin
User 665831-Jul-03 2:11
User 665831-Jul-03 2:11 
GeneralRe: _beginthread newbie question Pin
Vitali Halershtein31-Jul-03 4:55
Vitali Halershtein31-Jul-03 4:55 
GeneralRe: _beginthread newbie question Pin
tareqsiraj31-Jul-03 6:53
tareqsiraj31-Jul-03 6:53 
GeneralSelecting multiple files in subdirectories Pin
BoudewijnEctor31-Jul-03 1:20
BoudewijnEctor31-Jul-03 1:20 
GeneralRe: Selecting multiple files in subdirectories Pin
Ted Ferenc31-Jul-03 1:33
Ted Ferenc31-Jul-03 1:33 
GeneralRe: Selecting multiple files in subdirectories Pin
Jim Crafton31-Jul-03 8:19
Jim Crafton31-Jul-03 8:19 
GeneralDead windows in MFC Pin
BoudewijnEctor31-Jul-03 0:59
BoudewijnEctor31-Jul-03 0:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.