Book description
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 CRC32 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
Floatingpoint to/from integer conversions
Approximate floatingpoint reciprocal square root routine
A gallery of graphs of discrete functions
Now with exercises and answers
Table of contents
 Title Page
 Copyright Page
 Dedication Page
 Contents
 Foreword
 Preface
 Chapter 1. Introduction

Chapter 2. Basics
 2–1 Manipulating Rightmost Bits
 2–2 Addition Combined with Logical Operations
 2–3 Inequalities among Logical and Arithmetic Expressions
 2–4 Absolute Value Function
 2–5 Average of Two Integers
 2–6 Sign Extension
 2–7 Shift Right Signed from Unsigned
 2–8 Sign Function
 2–9 ThreeValued Compare Function
 2–10 Transfer of Sign Function
 2–11 Decoding a “Zero Means 2**n” Field
 2–12 Comparison Predicates
 2–13 Overflow Detection
 2–14 Condition Code Result of Add, Subtract, and Multiply
 2–15 Rotate Shifts
 2–16 DoubleLength Add/Subtract
 2–17 DoubleLength Shifts
 2–18 Multibyte Add, Subtract, Absolute Value
 2–19 Doz, Max, Min
 2–20 Exchanging Registers
 2–21 Alternating among Two or More Values
 2–22 A Boolean Decomposition Formula
 2–23 Implementing Instructions for All 16 Binary Boolean Operations
 Chapter 3. Powerof2 Boundaries
 Chapter 4. Arithmetic Bounds
 Chapter 5. Counting Bits
 Chapter 6. Searching Words

Chapter 7. Rearranging Bits and Bytes
 7–1 Reversing Bits and Bytes
 7–2 Shuffling Bits
 7–3 Transposing a Bit Matrix
 7–4 Compress, or Generalized Extract
 7–5 Expand, or Generalized Insert
 7–6 Hardware Algorithms for Compress and Expand
 7–7 General Permutations, Sheep and Goats Operation
 7–8 Rearrangements and Index Transformations
 7–9 An LRU Algorithm
 Chapter 8. Multiplication
 Chapter 9. Integer Division

Chapter 10. Integer Division By Constants
 10–1 Signed Division by a Known Power of 2
 10–2 Signed Remainder from Division by a Known Power of 2
 10–3 Signed Division and Remainder by NonPowers of 2
 10–4 Signed Division by Divisors ≥ 2
 10–5 Signed Division by Divisors ≤ –2
 10–6 Incorporation into a Compiler
 10–7 Miscellaneous Topics
 10–8 Unsigned Division
 10–9 Unsigned Division by Divisors ≥ 1
 10–10 Incorporation into a Compiler (Unsigned)
 10–11 Miscellaneous Topics (Unsigned)
 10–12 Applicability to Modulus and Floor Division
 10–13 Similar Methods
 10–14 Sample Magic Numbers
 10–15 Simple Code in Python
 10–16 Exact Division by Constants
 10–17 Test for Zero Remainder after Division by a Constant
 10–18 Methods Not Using Multiply High
 1019 Remainder by Summing Digits
 10–20 Remainder by Multiplication and Shifting Right
 10–21 Converting to Exact Division
 10–22 A Timing Test
 10–23 A Circuit for Dividing by 3
 Chapter 11. Some Elementary Functions
 Chapter 12. Unusual Bases for Number Systems
 Chapter 13. Gray Code
 Chapter 14. Cyclic Redundancy Check
 Chapter 15. ErrorCorrecting Codes

Chapter 16. Hilbert’s Curve
 16–1 A Recursive Algorithm for Generating the Hilbert Curve
 16–2 Coordinates from Distance along the Hilbert Curve
 16–3 Distance from Coordinates on the Hilbert Curve
 16–4 Incrementing the Coordinates on the Hilbert Curve
 16–5 NonRecursive Generating Algorithms
 16–6 Other SpaceFilling Curves
 16–7 Applications
 Chapter 17. FloatingPoint
 Chapter 18. Formulas For Primes

Answers To Exercises
 Chapter 1: Introduction
 Chapter 2: Basics
 Chapter 3: Powerof2 Boundaries
 Chapter 4: Arithmetic Bounds
 Chapter 5: Counting Bits
 Chapter 6: Searching Words
 Chapter 7: Rearranging Bits and Bytes
 Chapter 8: Multiplication
 Chapter 9: Integer Division
 Chapter 10: Integer Division by Constants
 Chapter 11: Some Elementary Functions
 Chapter 12: Unusual Bases for Number Systems
 Chapter 13: Gray Code
 Chapter 14: Cyclic Redundancy Check
 Chapter 15: ErrorCorrecting Codes
 Chapter 16: Hilbert’s Curve
 Chapter 17: FloatingPoint
 Chapter 18: Formulas for Primes
 Appendix A. Arithmetic Tables for A 4Bit Machine
 Appendix B. Newton’s Method
 Appendix C. A Gallery of Graphs of Discrete Functions
 Bibliography
 Index
 Footnotes
Product information
 Title: Hacker’s Delight, Second Edition
 Author(s):
 Release date: September 2012
 Publisher(s): AddisonWesley Professional
 ISBN: 9780133084993
You might also like
book
TCP/IP Illustrated, Volume 1: The Protocols, 2nd Edition
“For an engineer determined to refine and secure Internet operation or to explore alternative solutions to …
book
Hacker's Delight
"This is the first book that promises to tell the deep, dark secrets of computer arithmetic, …
book
Understanding the Linux Kernel, 3rd Edition
In order to thoroughly understand what makes Linux tick and why it works so well on …
video
Linux Fundamentals, 2nd Edition
10+ Hours of Video Instruction More than 10 hours of video instruction to get you up …