@crossrulz wrote:
@GerdW wrote:
Hi Jeff,
I don't get your math…
How is
checksum = 256 mod (checksum);
equivalent to
if (checksum > 255) checksum -= 255;
???
Example:
checksum := 270 (before math routine).
Your result: checksum = (256 mod 270) = 256
OP wanted: checksum = 270-255 = 15
Jeff's nomenclature is backwards. It really should be:
checksum mod 255
That would match what the OP stated. If you just add bytes and ignore the overflow (the way much checksums work), it would be a mod 256.
Ah, my C+× IS rusty, not my math! 😉
"Should be" isn't "Is" -Jay