RE: [DUG]: C Conversion

2003-11-04 Thread James Sugrue
h Sent: Tuesday, 4 November 2003 1:48 p.m. To: Multiple recipients of list delphi Subject: Re: [DUG]: C Conversion Use Cardinal instead of Integer - because the C code uses "unsigned int". Your for should be 0-based: for currByte := 0 to dataLength-1 do ^ maps to xor if ((dat

Re: [DUG]: C Conversion

2003-11-04 Thread Bevan Edwards
The comment about C using "unsigned int" is a good point.   You changed the line:   if ((dataStore ^ accum) & 0x8000) to:   if ((dataStore or accum) and $8000) > 0 then   which isn't technically correct.  It would be correct if you were using an unsigned type but, if you are using a signed t

Re: [DUG]: C Conversion

2003-11-04 Thread Pedrocelli
James, I see you have converted unsigned integers to "Integer", which is a signed type.  Shouldn't they be converted to Longword or Word types, which are unsigned, depending on how C implements "unsigned int"?   Just my 2 cents worth Pedrocelli   - Original Message - From: James Sugr

Re: [DUG]: C Conversion

2003-11-04 Thread Dennis Chuah
Use Cardinal instead of Integer - because the C code uses "unsigned int". Your for should be 0-based: for currByte := 0 to dataLength-1 do ^ maps to xor if ((dataStore xor accum) and $8000) > 0 then accum := (accum shl 1) xor CRCDIV; Lastly, this does not affect your code, but

RE: [DUG]: C Conversion

2003-11-03 Thread James Sugrue
Yes you’re right. Thanks. (Slap myself about the head)   From: owner-[EMAIL PROTECTED] [mailto:owner-[EMAIL PROTECTED]] On Behalf Of Paul Heinz Sent: Tuesday, 4 November 2003 12:45 p.m. To: Multiple recipients of list delphi Subject: RE: [DUG]: C Conversion   James asked

Re: [DUG]: C Conversion

2003-11-03 Thread gajo
I'm not sure, but perhaps it's this line: dataStore := Integer(data[currByte]) shl 8; I didn't know you can convert a PChar to Integer like that. Anyway, I wrote a small example like this: var p: PChar; a : integer; begin p := '5'; a := Integer(p); Caption := IntToStr(a) And the Caption doesn

RE: [DUG]: C Conversion

2003-11-03 Thread Paul Heinz
James asked:    [snip]     if ((dataStore ^ accum) & 0x8000) {     accum = (accum << 1) ^ CRCDIV;    [snip]   if ((dataStore or accum) and $8000) > 0 then   begin     accum := (accum shl 1) or CRCDIV;  Note that the ^ operator in C is Xor,

RE: [DUG]: C Conversion

2003-11-03 Thread James Sugrue
Might be but hasn’t fixed problem.   From: owner-[EMAIL PROTECTED] [mailto:owner-[EMAIL PROTECTED]] On Behalf Of Jason Coley Sent: Tuesday, 4 November 2003 12:05 p.m. To: Multiple recipients of list delphi Subject: RE: [DUG]: C Conversion   Should it be 0 to dataLength – 1

RE: [DUG]: C Conversion

2003-11-03 Thread Jason Coley
Should it be 0 to dataLength – 1 ?   And 0 to 7 ?   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Sugrue Sent: Tuesday, 4 November 2003 12:00 p.m. To: postmaster Subject: [DUG]: C Conversion   I have the following code. I have tried to convert into Del