Does anyone have a J-ish solution to adler32 checksum and avoid overflow to floating points ?
Adler-32 is composed of two sums accumulated per byte: s1 is the sum of all bytes, s2 is the sum of all s1 values. Both sums are done modulo 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored as s2*65536 + s1 in most- significant-byte first (network) order. * https://www.ietf.org/rfc/rfc1950.txt * http://en.wikipedia.org/wiki/Adler-32 direct translation to J adler32=: 3 : 0 's1 s2'=. 1 0 for_a. a.i.y do. s1=. 65521 | s1 + a s2=. 65521 | s2 + s1 end. s1 + 16 (33 b.) s2 ) test data: adler32 'Wikipedia' 300286872 adler32 'The quick brown fox jumps over the lazy dog' 1541148634 -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
