17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

20.3 Cyclic Redundancy and Other Checksums 901<br />

table). If jinit is negative, then crc is used on input to initialize the remainder register, in<br />

effect (for crc set to the last returned value) concatenating bufptr to the previous call.<br />

{<br />

unsigned short icrc1(unsigned short crc, unsigned char onech);<br />

static unsigned short icrctb[256],init=0;<br />

static uchar rchr[256];<br />

unsigned short j,cword=crc;<br />

static uchar it[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};<br />

Table of 4-bit bit-reverses.<br />

}<br />

if (!init) { Do we need to initialize tables?<br />

init=1;<br />

for (j=0;j= 0) cword=((uchar) jinit) | (((uchar) jinit)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!