Checksum c/c++ code example, Add with Carry



#include stdio.h

#include string.h




int DataLen=5;

const char* pData="ABCDE";



unsigned short CalculateChecksum (const unsigned char* pData, int DataLen);



main()




{



unsigned long CS = 0;

unsigned short* psData = (unsigned short*)pData;

for (int Index = 0; Index < (DataLen / 2); Index++, psData++)



CS += *psData;



if (DataLen % 2 != 0)

CS += pData[DataLen - 1];

CS = (CS >> 16) + (CS & 0xFFFF);

CS += (CS >> 16);



printf("%4x", CS);



return (unsigned short) ~CS;



}







-----------------------------



ABCDE




step1.




AB->BA




CD->DC




E->0E




Step2.




Sum




BA+DC+0E




---------------------------------------------


step3.




When you get to lager sums carry must be added back to the original number.




ex. x12345




=x1234+5=x1239

Interpret the Dream, A dream to clean the bathroom

I dreamed of cleaning up the presidential room in my dreams and clearing all the shit on the walls.


I bought a lottery ticket because I did not like it.


I am so happy that I have a day and a lottery ...


The result is bang!


How can there be no number?


Even after the disappointment of dog dreams, paying movies ...


I woke up the next morning and the movie I paid for yesterday was released for the first time.


Ha ~~~


This is a very bad dream.

2026년 스포츠 토토 베트맨 축구 배팅 55회차 라리가 RC셀타비고 vs 레반테 예상 전략

  스포츠 배팅 최종 전략 보고서: RC셀타비고 vs 레반테 이번 배팅 슬립에 대한 철저한 분석을 바탕으로, 현재 선택의 적절성 평가 및 최종 전략을 제시합니다. 1. 【슬립 전체 평가】 배당 분석(EV·Bias) 및 기댓값 평가: 현재 슬립에 포함된...