Book description
"This is the first book that promises to tell the deep, dark secrets of computer arithmetic, and it delivers in spades. It contains every trick I knew plus many, many more. A godsend for library developers, compiler writers, and lovers of elegant hacks, it deserves a spot on your shelf right next to Knuth."
Josh Bloch
"When I first saw the title, I figured that the book must be either a cookbook for breaking into computers (unlikely) or some sort of compendium of little programming tricks. It's the latter, but it's thorough, almost encyclopedic, in its coverage."
Guy Steele
These are the timesaving techniques relished by computer hackersthose devoted and persistent code developers who seek elegant and efficient ways to build 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 techniques 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 broad collection of useful programming tricks
Small algorithms for common tasks
Powerof2 boundaries and bounds checking
Rearranging bits and bytes
Integer division and division by constants
Some elementary functions on integers
Gray code
Hilbert's spacefilling curve
And even formulas for prime numbers!
This book is for anyone who wants to create efficient code. Hacker's Delight will help you learn to program at a higher levelwell beyond what is generally taught in schools and training coursesand will advance you substantially further than is possible through ordinary selfstudy alone.
0201914654B06272002
Table of contents
 Copyright
 Foreword
 Preface
 Introduction

Basics
 Manipulating Rightmost Bits
 Addition Combined with Logical Operations
 Inequalities among Logical and Arithmetic Expressions
 Absolute Value Function
 Sign Extension
 Shift Right Signed from Unsigned
 Sign Function
 ThreeValued Compare Function
 Transfer of Sign
 Decoding a “Zero Means 2**n” Field
 Comparison Predicates
 Overflow Detection
 Condition Code Result of Add, Subtract, and Multiply
 Rotate Shifts
 DoubleLength Add/Subtract
 DoubleLength Shifts
 Multibyte Add, Subtract, Absolute Value
 Doz, Max, Min
 Exchanging Registers
 Alternating among Two or More Values
 Powerof2 Boundaries
 Arithmetic Bounds
 Counting Bits
 Searching Words
 Rearranging Bits and Bytes
 Multiplication
 Integer Division

Integer Division by Constants
 Signed Division by a Known Power of 2
 Signed Remainder from Division by a Known Power of 2
 Signed Division and Remainder by NonPowers of 2
 Signed Division by Divisors ≥ 2
 Signed Division by Divisors ≤ 2
 Incorporation into a Compiler
 Miscellaneous Topics
 Unsigned Division
 Unsigned Division by Divisors ≥ 1
 Incorporation into a Compiler (Unsigned)
 Miscellaneous Topics (Unsigned)
 Applicability to Modulus and Floor Division
 Similar Methods
 Sample Magic Numbers
 Exact Division by Constants
 Test for Zero Remainder after Division by a Constant
 Some Elementary Functions
 Unusual Bases for Number Systems
 Gray Code
 Hilbert’s Curve
 FloatingPoint
 Formulas for Primes
 Arithmetic Tables for a 4Bit Machine
 Newton’s Method
 Bibliography
Product information
 Title: Hacker's Delight
 Author(s):
 Release date: July 2002
 Publisher(s): AddisonWesley Professional
 ISBN: 9780201914658
You might also like
book
Hacker’s Delight, Second Edition
In Hank Warren once again compiles an irresistible collection of programming hacks: timesaving techniques, algorithms, and …
book
Hands on Hacking
A fast, handson introduction to offensive hacking techniques HandsOn Hacking teaches readers to see through the …
book
Gray Hat Hacking: The Ethical Hacker's Handbook, Sixth Edition, 6th Edition
Uptodate strategies for thwarting the latest, most insidious network attacks This fully updated, industrystandard security resource …
audiobook
Hacking Artificial Intelligence
We are accelerating towards the automated future. But this new future brings new risks. It is …