Hacker's Delight"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 (Praise for the first edition) 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
|
Contents
CHAPTER 1 INTRODUCTION | 1 |
CHAPTER 2 BASICS | 11 |
CHAPTER 3 POWEROF2 BOUNDARIES | 59 |
CHAPTER 4 ARITHMETIC BOUNDS | 67 |
CHAPTER 5 COUNTING BITS | 81 |
CHAPTER 6 SEARCHING WORDS | 117 |
CHAPTER 7 REARRANGING BITS AND BYTES | 129 |
CHAPTER 8 MULTIPLICATION | 171 |
CHAPTER 14 CYCLIC REDUNDANCY CHECK | 319 |
CHAPTER 15 ERRORCORRECTING CODES | 331 |
CHAPTER 16 HILBERTS CURVE | 355 |
CHAPTER 17 FLOATINGPOINT | 375 |
CHAPTER 18 FORMULAS FOR PRIMES | 391 |
ANSWERS TO EXERCISES | 405 |
APPENDIX A ARITHMETIC TABLES FOR A 4BIT MACHINE | 453 |
APPENDIX B NEWTONS METHOD | 457 |
Other editions - View all
Common terms and phrases
32 bits 32-bit machine algorithm apply arithmetic array base basic RISC instructions binary bit positions Boolean branch-free byte calculated check bits checksum code of Figure code words column complement compute constant correct cycles denotes digits divide dividend divisor Equation error example executes expression floating-point formula formula for primes function gives Gray code Hamming code hexadecimal high-order bit Hilbert curve implemented information bits integer square root iteration leading zeros length load loop magic number mask matrix method modulo multiplicative inverse negative number of 1-bits number of leading operands operation overflow parity bit perfect shuffle permutation polynomial population count predicate quantity quotient range remainder modulo requires result return q rightmost rotate shift amount shift left shift right shown in Figure sign bit simple string of 1’s subtraction swap table lookup theorem tion unsigned division unsigned integers variables