Fletcher-16 calculator in BASIC

Camerart

Member
Hi,
I have to carry out Fletcher-16 calculated checksums, in BASIC.

Does anyone have such CODE, please?
Camerart
 

Cromewell

Administrator
Staff member
It should be easy enough to implement. I grabbed this description from KSU, https://people.cs.ksu.edu/~schmidt/115/ch5.html
They also include an example calculation so that it is easier to understand, just search the page for "Fletcher's checksum"
Fletcher's checksum algorithm

INPUT: a data word (e.g., a sequence of ASCII-numbers)
OUTPUT: two checksums for the word, each sized to fit in one byte
ALGORITHM:
1. divide the Word into a sequence of equally-sized blocks, b1 b2 ... bn
2. define two checksums, starting at C1 = 0 and C2 = 0
3. for each block, b1, b2, b3, etc
add block to C1
add the new value of C1 to C2
4. compute Checksum1 = C1 mod 255 and Checksum2 = C2 mod 255
5. return Checksum1 and Checksum2
There is a more complicated explanation on Wikipedia, which also has implementations in C

If you need help with specific spots you can ask. but this feels homeworky so regardless of whether it actually is or not, I won't just offer complete code.
 

Camerart

Member
It should be easy enough to implement. I grabbed this description from KSU, https://people.cs.ksu.edu/~schmidt/115/ch5.html
They also include an example calculation so that it is easier to understand, just search the page for "Fletcher's checksum"

There is a more complicated explanation on Wikipedia, which also has implementations in C

If you need help with specific spots you can ask. but this feels homeworky so regardless of whether it actually is or not, I won't just offer complete code.
Hi C,
I saw the more complicated version, then came here for your simpler one, thanks.

I'm long past homework!

Ok, I'll try to write it (BASIC) which will take a while,as at the moment I'm using examples.
C.
 
Top