3 ms·
Daniel J. Bernstein
- tunap 4y 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.
- 0des 4y 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 http://www.cse.yorku.ca/~oz/hash.html