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
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
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
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
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
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
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,
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
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