ArticleslgStudy

computer science

Hacker's Delight

Hacker's Delight is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hacker's Delight rather than just read about it. In short: Hacker's Delight is a software algorithm book by Henry S. Warren, Jr. first published in 2002.

Hacker's Delight — main illustration
Hacker's Delight — illustration

Key takeaways

  • Hacker's Delight belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hacker's Delight to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hacker's Delight from memory before moving on to harder problems.

Reference excerpt

Hacker's Delight is a software algorithm book by Henry S. Warren, Jr. first published in 2002. It presents fast bit-level and low-level arithmetic algorithms for common tasks such as counting bits or improving speed of division by using multiplication.

Background The author, an IBM researcher working on systems ranging from the IBM 704 to the PowerPC, collected what he called "programming tricks" over the course of his career. These tricks concern efficient low-level manipulation of bit strings and numbers. According to the book's foreword by Guy L. Steele, the target audience includes compiler writers and people writing high-performance code.

Summary Programming examples are written in C and assembler for a RISC architecture similar, but not identical to PowerPC. Algorithms are given as formulas for any number of bits, the examples usually for 32 bits. Apart from the introduction, chapters are independent of each other, each focusing on a particular subject. Many algorithms in the book depend on two's complement integer numbers. The subject matter of the second edition of the book includes algorithms for

Basic algorithms for manipulating individual bits, formulas for identities, inequalities, overflow detection for arithmetic operations and shifts Rounding up and down to a multiple of a known power of two, the next power of two and for detecting whether an operation crossed a power-of-two boundary Checking bounds Counting total, leading and trailing zeros Searching for bit strings Permutations of bits and bytes in a word Software algorithms for multiplication Integer division Efficient integer division and calculating of the remainder when the divisor is known Integer square and cube roots Unusual number systems, including base −2 Transfer of values between floating-point and integer Cyclic redundancy checks, error-correcting codes and Gray codes Hilbert curves, including a discussion of applications

Style The style is that of an informal mathematical textbook. Formulas are used extensively. Mathematical proofs are given for some non-obvious algorithms, but are not the focus of the book.

Reception Overall reception has been generally positive.

Publication history The book was published by Addison-Wesley Professional. The first edition was released in 2002 and the second in 2013. Japanese language edition of this book was published by SIBaccess Co. Ltd., in 2004.

See also HAKMEM Popcount Find first set

References

Further reading Beeler, Michael; Gosper, Ralph William; Schroeppel, Richard C. (April 1995) [1972-02-29]. "Artificial Intelligence Memo No. 239". In Baker, Henry Givens Jr. (ed.). HAKMEM (retyped & converted ed.). Cambridge, Massachusetts, USA: Artificial Intelligence Laboratory, Massachusetts Institute of Technology (MIT). Archived from the original on 2019-10-08. Retrieved 2016-01-02. Jones, Douglas W. (2014-09-10) [1999]. "Arithmetic Tutorials". Iowa City, Iowa, USA: The University of Iowa, Department of Computer Science. Archived from the original on 2019-07-10. Retrieved 2016-01-03. Cowlishaw, Mike F. (2015) [1981, 2008]. "General Decimal Arithmetic". Archived from the original on 2019-11-02. Retrieved 2016-01-02. Ingenoso, Tony (1999-02-03) [1998]. "Chapter 11 - More tricks in C and Assembler code". Making Code Work Better - How to minimize the size of 80x86 code and sometimes make it faster (e-book). Archived from the original on 2019-11-18. Retrieved 2019-11-18. Anderson, Sean Eron, ed. (2009-11-26) [1997]. "Bit Twiddling Hacks". Stanford University. Archived from the original on 2020-06-01. Retrieved 2020-06-01.

External links Archive of Hacker's Delight website

Worked examples

Example 1 — a first encounter with Hacker's Delight

Start with the simplest possible case. Write down what Hacker's Delight claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hacker's Delight before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hacker's Delight ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hacker's Delight

In research
Hacker's Delight appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hacker's Delight in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hacker's Delight is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2002 non-fiction books, 2013 non-fiction books, Addison-Wesley books, so understanding it makes those chapters shorter.
In everyday life
Look for Hacker's Delight outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Hacker's Delight” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Hacker's Delight in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hacker's Delight means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hacker's Delight out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hacker's Delight in simple terms?

Hacker's Delight is a software algorithm book by Henry S. Warren, Jr. first published in 2002.

Why does Hacker's Delight matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hacker's Delight?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hacker's Delight.

Tags

  • 2002 non-fiction books
  • 2013 non-fiction books
  • Addison-Wesley books
  • Computer programming books
  • Computer science books

Keep exploring