Settings

Theme

Daniel J. Bernstein

en.wikipedia.org

6 points by 0des 3 years ago · 2 comments

Reader

0desOP 3 years ago

> djb2

> this algorithm (k=33) was first reported by dan bernstein many years ago in comp.lang.c. another version of this algorithm (now favored by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained.

    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;
    }
source: http://www.cse.yorku.ca/~oz/hash.html
tunap 3 years ago

"Hopes and fears draw in bold strokes, while knowledge advances by small increments & contradictory witnesses."

His are some of my favorite history books. The Discoverers is a great read, but you could just as easily thumb through and just pick a subject to learn about it's origins... it is a long, history of nearly everything(1). I also highly recommend "The Scene". An oldie but a goodie... so, so far ahead of it's time.

(1)Bryson appears to be a fan, too, as he cites DJB twice in his "At Home" book.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection