Hacker's Delight / Edition 1by Henry S. Warren
Pub. Date: 07/28/2002
These are the timesaving techniques relished by computer hackersthose devoted and persistent problem-solvers engrossed in their code who seek elegant and efficient solutions for building better software. The truth is that much of the computer programmer/p>
At long last, a collection of shortcuts for the programming trade, organized thematically in one volume!
These are the timesaving techniques relished by computer hackersthose devoted and persistent problem-solvers engrossed in their code who seek elegant and efficient solutions for building better software. The truth is that much of the computer programmer's job involves a healthy mix of arithmetic and logic. In Hacker's Delight, veteran programmer Hank Warren shares the tricks he has collected from his considerable experience in the worlds of application and system programming. Most of these devices are eminently practical, but a few are included just because they are interesting and unexpected. The resulting work is an irresistible collection that will help even the most seasoned programmers better their craft.
Topics covered include:
- A collection useful programming devices the author has collected over the years
- Small algorithms for common tasks
- Power-of-2 boundaries and bounds checking
- Rearranging bits and bytes
- Integer division and division by constants
- Some elementary functions on integers
- Gray code
- Hilbert's space-filling curve
- And even formulas for prime numbers!
This book is for anyone who wants to create efficient code. With the help of Hacker's Delight, you will learn to program at a higher level than is generally taught in schools or training courses, and you will advance substantially more than you would through self-directed study.
- Publication date:
- Edition description:
- Older Edition
- Product dimensions:
- 6.50(w) x 9.37(h) x 0.81(d)
Table of ContentsPreface.
Instruction Set and Execution Time Model.
Addition Combined with Logical Operations.
Inequalities among Logical and Arithmetic Expressions.
Shift Right Signed from Unsigned.
Transfer of Sign.
Decoding a “Zero Means 2**n” Field.
Condition Code Result of Add, Subtract, and Multiply.
Multibyte Add, Subtract, Absolute Value.
Doz, Max, Min.
Alternating among Two or More Values.
3. Power-of-2 Boundaries.
Rounding up/down to the Next Power of 2.
Detecting a Power-of-2 Boundary Crossing.
4. Arithmetic Bounds.
Propagating Bounds through Adds and Subtracts.
Propagating Bounds through Logical Operations.
5. Counting Bits.
Counting Leading Zeros.
Counting Trailing Zeros.
6. Searching Words.
Find First String of 1-bits of a Given Length.
7. Rearranging Bits and Bytes.
Transposing a Bit Matrix.
Compress, or Generalized Extract.
General Permutations, Sheep and Goats Operation.
Rearrangements and Index Transformations.
High-order Half of 64-bit Product.
High-order Product Signed from/to Unsigned.
Multiplication by Constants.
9. Integer Division.
Unsigned Short Division from Signed Division.
Unsigned Long Division.
10. Integer Division by Constants.
Signed Remainder from Division by a Known Power of 2.
Signed Division and Remainder by Non-powers of 2.
Signed Division by Divisors >= 2.
Signed Division by Divisors <= -2.
Incorporation into a compiler.
Unsigned Division by Divisors >= 1.
Incorporation into a Compiler (unsigned).
Miscellaneous Topics (unsigned).
Applicability to Nodulus and floor division.
Sample Magic Numbers.
Exact Division by constants.
Test for Zero Remainder after Division by a Bonstant.
11. Some Elementary Functions.
Integer Cube Root.
12. Unusual Bases for Number Systems.
Base -1 + i.
What is the Most Efficient Base?
13. Gray Code.
Incrementing a Gray Coded Integer.
Negabinary Gray Code.
Brief History and Applications.
14. Hilbert's Curve.
Coordinates from Distance along the Hilbert Curve.
Distance from Coordinates on the Hilbert Curve.
Incrementing the Coordinates on the Hilbert Curve.
Non-recursive Generating Algorithms.
Other Space-filling Curves.
Comparing Floating-point Numbers Using Integer Operations.
The Distribution of Leading Digits.
Table of Miscellaneous Values.
16. Formulas for Primes.
Formulas for Other Difficult Functions.
Appendix A. Arithmetic Tables for a Four-Bit Machine.
Appendix B. Newton's Method.
and post it to your social network
Most Helpful Customer Reviews
See all customer reviews >
At first sight, the book seemed a bit short for $40. But there is quite a bit of information packed in there, and it's certainly much easier to comprehend than picking up one of Knuth's books for the first time. With that said, this really is a book for computer engineers, i.e. people who really like to know what's going on at the bit level. The bit manipulation examples are given in pseudo-assembly, which is very applicable. I can't give 5 stars because of the niche target audience, but it is a very concise, interesting read.