TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Daniel J. Bernstein

6 点作者 0des将近 3 年前

2 条评论

0des将近 3 年前
&gt; djb2<p>&gt; 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.<p><pre><code> unsigned long hash(unsigned char *str) { unsigned long hash = 5381; int c; while (c = *str++) hash = ((hash &lt;&lt; 5) + hash) + c; &#x2F;* hash * 33 + c *&#x2F; return hash; } </code></pre> source: <a href="http:&#x2F;&#x2F;www.cse.yorku.ca&#x2F;~oz&#x2F;hash.html" rel="nofollow">http:&#x2F;&#x2F;www.cse.yorku.ca&#x2F;~oz&#x2F;hash.html</a>
tunap将近 3 年前
&quot;Hopes and fears draw in bold strokes, while knowledge advances by small increments &amp; contradictory witnesses.&quot;<p>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&#x27;s origins... it is a long, history of nearly everything(1). I also highly recommend &quot;The Scene&quot;. An oldie but a goodie... so, so far ahead of it&#x27;s time.<p>(1)Bryson appears to be a fan, too, as he cites DJB twice in his &quot;At Home&quot; book.