Tutorials - Billy Belcebu Virus Writing Guide 1.04. Bit Twiddling Hacks. By Sean Eron Anderson seander@cs.stanford.edu Individually, the code snippets here are in the public domain (unless otherwise noted) — feel free to use them however you please. The aggregate collection and descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and without even the implied warranty of merchantability or fitness for a particular purpose.
As of May 5, 2005, all the code has been tested thoroughly. Thousands of people have read it. Moreover, Professor Randal Bryant, the Dean of Computer Science at Carnegie Mellon University, has personally tested almost everything with his Uclid code verification system. Contents About the operation counting methodology When totaling the number of operations for algorithms here, any C operator is counted as one operation.
Compute the sign of an integer The last expression above evaluates to sign = v >> 31 for 32-bit integers. Sign = (v ! Sean A. Programmers' Tools | Tools for real coders. C, C++, Java, Assembler, Basic, Pascal, PHP, Ruby, Scripts, Setup, Debugging, Debuggers, Version Control. Art of Assembly Language Programming and HLA by Randall Hyde. Published by No Starch Press (Second Edition is now available!) ( You can order this book from as well as your local bookseller Click HERE to see a larger version of the cover art. Now Available! Write Great Code, Volume I: Understanding the Machine Randy Hyde's new series: Write Great Code teaches you everything you need to know to write efficient, readable, maintainable, and quality code.
The first volume in this four-volume set, Understanding the Machine, teaches 'Machine Organization'. This book will also make a great companion/prerequisite text to "The Art of Assembly Language" Click Here for more information about the Write Great Code series Click HERE to see a larger version of the cover art. Write Great Code, Volume II: Thinking Low-Level, Writing High-Level Compiler writers have often claimed that their compilers generate code that is just as good as hand-written assembly language. Click HERE to see a larger version of the cover art.