> > does anyone know if the function /sys/src/cmd/snap/take.c:/^sumr > > can return 0 for a buffer that is not all zeros? > > > > i think it can not, since for sum&1, the next sum at least > > has 0x8000 set and otherwise if (sum&1) == 0, then either > > sum == 0 or sum>>1 != 0. > > >> if(sum & 1) > >> sum = 0xffff & ((sum>>1)+*s+0x8000); > >> else > >> sum = 0xffff & ((sum>>1)+*s); > > your logic does not account for the addition of *s, > which can cause an overflow that clears the 0x8000 bit. > ff 80 80 80 80 80 80 80 80 01. >
d'oh. i must need more sleep. i forgot to add *s back in. thanks for the historical perspective. - erik
