自己写不行吗?简单的相加,只是注意和超过0X10000时要将和-0X10000+1
解决方案 »
- CTreeCtrl使用过程的小问题,求指教
- 今天在淘宝上碰到一个骗子
- 数据库连接问题
- 如何获取用户新插入移动设备的盘符?
- 自己封装一个SOCKET类,出现了错误
- 关于做语音网关,有没有人知道这样一块内容,有哪些东西要准备!
- 疑惑,如何判断一个文件是二进制文件,还是文件文件?
- 两个进程间来回切换,程序的激活状态,SetForegroudWindow与SetActiveWindow等等API都没有用,真是奇怪?
- 使用MFC向导生成的未加改动的ISAPI的DLL,500服务器内部错误,为什么
- 怎样使用streamout将CRichEditCtrl的内容存到数据库中!
- vc中更改显示器分辩率
- 问个问提~~~~~~~有关编译技巧的
{
register int nleft = len;
register u_short *w = (u_short *)packet;
register int sum = 0;
u_short answer = 0; /*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1)
{
sum += *w++;
nleft -= 2;
} /* mop up an odd byte, if necessary */
if (nleft == 1)
{
*(u_char *)(&answer) = *(u_char *)w ;
sum += answer;
} /* add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return(answer);
}