tags:

views:

157

answers:

1

i just stumbled onto this comment.

    public static int lowestOneBit(int i) {
    // HD, Section 2-1
    return i & -i;
    }

in the 1.5 java source. what does this comment mean? is it a reference to a book? a spec?

+12  A: 

HD probably refers to Hacker's Delight by Henry S. Warren. Indeed, this formula appears on page 11, section 2-1.

Greg Hewgill
Agreed. The documentation for java.lang.Long tells us »Implementation note: The implementations of the "bit twiddling" methods (such as highestOneBit and numberOfTrailingZeros) are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).«
Joey