[Jprogramming] Adler-32

Raul Miller rauldmiller at gmail.com
Sun Aug 24 14:11:50 UTC 2014


On Sun, Aug 24, 2014 at 6:43 AM, mike_liz.day at tiscali.co.uk
<mike_liz.day at tiscali.co.uk> wrote:
> I continue to be puzzled by the poor performance of something
> like add32/\ compared to +/\  .

The answer, here, can be explained in terms of an issue which I remember
being taught in gradeschool - "the associative law". (Of course, most
gradeschool students are not sufficiently terrified or interested or whatever
it takes, to retain an interest in such things.)

u/\ 1 2 3 4 is

1, (1 u 2), (1 u (2 u 3)), (1 u (2 u (3 u 4)))

+ is known to be associative, so +/\ rearranges the order of computation,
and instead computes this sequence:

1, (1+2), ((1+2)+3), (((1+2)+3)+4)

Note also that with floating point numbers addition is in some cases just
an approximation, so it's possible to construct a sequence of numbers
which reveals this issue.

Thanks,

-- 
Raul


More information about the Programming mailing list