Equotion explanation

Hello!
Please, can someone show me, if possible on example, how to we get that:
((hash << 5) + hash) + c = hash * 33 + c

Meaning:
((hash << 5) + hash) =hash * 33

Many thanks!!!

1
2
3
4
5
6
7
8
9
10
11
unsigned long
    hash(unsigned char *str)
    {
        unsigned long hash = 5381;
        int c;

        while (c = *str++)
            hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

        return hash;
    }
Last edited on
I thought your other thread did already provide you enough information.
Again: http://msdn.microsoft.com/en-us/library/336xbhcz.aspx

33 == 32+1
a*(b+c) == a*b + a*c
2^5 == 32
Topic archived. No new replies allowed.