Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ryesone.UUCP Path: utzoo!utcs!ryesone!mason From: mason@ryesone.UUCP (Dave Mason) Newsgroups: net.dcom,net.lan Subject: Re: Problem with CRC calculation...need help (solved my own problem) Message-ID: <132@ryesone.UUCP> Date: Sun, 6-Apr-86 16:55:13 EST Article-I.D.: ryesone.132 Posted: Sun Apr 6 16:55:13 1986 Date-Received: Mon, 7-Apr-86 11:04:22 EST References: <130@ryesone.UUCP> Distribution: net Organization: Ryerson School of Computer Science, Toronto, ON Lines: 36 Keywords: egg-on-my-face Xref: utcs net.dcom:1778 net.lan:1380 > I thought I had a working CRC routine, but it doesn't seem to net to > a zero. Turns out it *was* right, but I was mangling the checksum when I put it on the line. The error was in my routine to validate the crc. Basically I divided a negative number by 256 as an attempt to shift right by 8. > check(omsg) char *omsg; { > int i,j; > int ch; > char *msg; > printf(">>>>>>>>\n"); > msg=omsg; > crc=0; > while (ch = *msg++) > docrc(ch); > docrc(0); > docrc(0); > i=crc/256 % 256; <<<<<< i=crc>>8; > j=crc %256; > printf("------\n"); > msg=omsg; > crc=0; > while (ch = *msg++) > docrc(ch); > docrc(i); > docrc(j); > printf("crc=%d\n",crc); > } ------ I wish computers were as predictable as dice! -- usenet: ..!utzoo!utcsri!mason Dave Mason, U. Toronto CSRI ..!utzoo!ryesone!mason Dave Mason, Ryerson Polytechnical Institute CSNET: mason@Toronto ARPA: mason%Toronto@CSNet-Relay BITNET: FCTY7053@RYERSON.BITNET