CheckSumLong Function

Purpose

Computes the checksum for a range of bytes returning a 32-bit integer.

Syntax

sum = CheckSumLong(addr, count, [old])

sum, addr, count, old: iexp

Description

The function CheckSumLong() calculates a simple checksum (Long value) for a block of data: count bytes from the address addr. The optional parameter old is to be used if you want to create a checksum for more than one block, old must contain the checksum for the other block.

The checksum is a simple adding of 32-bit values in the data.

Example

Local a$, b$, ch_a%

Debug.Show

a$ = "This is a test"

b$ = "another block"

ch_a% = CheckSumLong(V:a$, Len(a$))

Trace CheckSumLong(V:a$, Len(a$))         // -112105912

Trace CheckSumLong(V:b$, Len(b$))         // -128892778

Trace CheckSumLong(V:a$, Len(a$), ch_a%// -224211823

Remarks

The calculation of data with CheckSumByte, CheckSumShort, CheckSumLong (or CheckXorxxx()) is very fast (up to 10 times faster than Crc16() or Crc32()).

A checksum is a form of redundancy check, a simple way to protect the integrity of data by detecting errors in data that are sent through space (telecommunications) or time (storage). It works by adding up the basic components of the data, typically the asserted bits, and storing the resulting value. Anyone can later perform the same operation on the data, compare the result to the authentic checksum, and (assuming that the sums match) conclude that the data was probably not corrupted.

See Also

CheckSumByte(), CheckSumLong(), CheckSumShort(), CheckXorByte(), CheckXorLong(), CheckXorShort(), Crc16(), Crc32()

{Created by Sjouke Hamstra; Last updated: 25/09/2014 by James Gaite}