Hacker's Delight, 2/e (Hardcover)

Henry S. Warren



In Hacker’s Delight, Second Edition, Hank Warren once again compiles an irresistible collection of programming hacks: timesaving techniques, algorithms, and tricks that help programmers build more elegant and efficient software, while also gaining deeper insights into their craft. Warren’s hacks are eminently practical, but they’re also intrinsically interesting, and sometimes unexpected, much like the solution to a great puzzle. They are, in a word, a delight to any programmer who is excited by the opportunity to improve.


Extensive additions in this edition include

  • A new chapter on cyclic redundancy checking (CRC), including routines for the commonly used CRC-32 code
  • A new chapter on error correcting codes (ECC), including routines for the Hamming code
  • More coverage of integer division by constants, including methods using only shifts and adds
  • Computing remainders without computing a quotient
  • More coverage of population count and counting leading zeros
  • Array population count
  • New algorithms for compress and expand
  • An LRU algorithm
  • Floating-point to/from integer conversions
  • Approximate floating-point reciprocal square root routine
  • A gallery of graphs of discrete functions
  • Now with exercises and answers



在《駭客的樂趣,第二版》中,Hank Warren再次匯集了一系列令人難以抗拒的程式設計技巧:節省時間的技巧、演算法和技巧,幫助程式設計師建立更優雅和高效的軟體,同時深入了解他們的工藝。Warren的技巧非常實用,但也具有內在的趣味性,有時候會出人意料,就像解決一個很棒的謎題一樣。總之,對於任何熱衷於改進的程式設計師來說,它們是一種樂趣。


- 一個關於循環冗餘檢查(CRC)的新章節,包括常用的CRC-32程式碼的例程
- 一個關於錯誤修正碼(ECC)的新章節,包括漢明碼的例程
- 更多關於整數除法的涵蓋範圍,包括僅使用位移和加法的方法
- 在不計算商數的情況下計算餘數
- 更多關於人口統計和計算前導零的涵蓋範圍
- 陣列人口統計
- 壓縮和展開的新演算法
- 一個最近最少使用(LRU)演算法
- 浮點數與整數之間的轉換
- 近似浮點數倒數平方根例程
- 一個離散函數圖庫
- 現在有練習和答案