Re: Bitwise AND

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Almon B. Strowger (strowger_at_NOSPAM.kook.com)
Date: 05/22/04


Date: Sat, 22 May 2004 00:05:18 -0700


Hi,

Try doing the AND after each add and see if it
works. Long is 64 bits. Integer is 32, so it is
probably a better choice. I'm not a VB.NET
person, but if your checksum really is supposed
to be that straightforward, the only thing I can
imagine that is happening is that you're causing
an overflow exception and that is what is causing
the problem. I THINK in VB.NET you can only
turn off overflow checking down to the source file
level (with a compiler switch) and not at the
statement level, but I'm not an expert. In any case,
if this is indeed the problem, my suggestion above
should prevent any overflow from happening.

Hope this helps...

Almon B. Strowger
KOOK Pocket Software

"Jonathan" <anonymous@discussions.microsoft.com> wrote in message
news:B65B751A-B4B8-4A73-85C8-73C5AE7C9703@microsoft.com...
> I am working on my application accept data through the serial port on the
PPC. I have a two byte checksum at the end of my data. I have added the sum
of all the preceeding characters but it never equals my check sum. I think
the problem is with the bitwise AND that I am uisng. This is because the
problem only occurs with the large packets of data. I did save the data and
imported into Excel. I found that it is good, but my comparisons are off. I
also know that the check sum is being calculated correctly on the PPC. The
character sum is off.
>
> I am using this code for the charsum:
>
> Dim CharSum as Long
> Dim CheckSum as Long
>
> ..................
>
> CharSum = CharSum And 65535
>
> if CharSum = CheckSum Then
> ..........
>
> I noticed in Vb.net there were several new types introduced. Is a Long a
16, 32, or 64 bit number? I know that a long with specific bits can be
defined, but I just used a plain Long. The number stored in CharSum could
easily reach 32 bits, or even 64. Am I using the wrong number types? Thanks
for the help.



Relevant Pages

  • [PATCH 2.6.9-rc1-mm4 5/6] [m32r] Update checksum functions
    ... -unsigned int csum_partial_copy(const char *src, char *dst, ... sum = csum_partial; ... Copy from userspace and compute checksum. ... -asmlinkage unsigned int csum_partial; ...
    (Linux-Kernel)
  • Re: Simple but reliable checksum for small controllers
    ... I am looking for an efficient checksum method. ... Just adding the code bytes to a 16/24/32-bit sum is simple ... The actual polynomial varies somewhat ...
    (comp.arch.embedded)
  • Re: MD5 Weakness Exploited
    ... While what they have achieved is not the same as producing an identical MD5 ... verified using a checksum from somewhere else. ... tools to verify that the download matches what was intended to retrieve. ... and the check sum from Keith's site. ...
    (comp.os.os2.apps)
  • simple transport protocol
    ... transfer data from host computer to target (ARM7-based embedded system) over ... It should not be very reliable, so a simple checksum algorithm can be ... ended with a control check sum. ... Command is to issue commans to target system such as start, stop, ...
    (comp.programming)