在java类的源代码中,什么意思是"HD"Integer和Long?

4 java comments bit-manipulation

在Integer.java和Long.java的源代码中,在大多数比特方法中,有一个注释引用了一个名为"HD"的东西.每种方法都指向所述参考的特定部分.

那是什么参考?


以下是highestOneBit(int)类中方法的示例Integer(此处为源代码,第1035行):

/**
 * Returns an {@code int} value with at most a single one-bit, in the
 * position of the highest-order ("leftmost") one-bit in the specified
 * {@code int} value.  Returns zero if the specified value has no
 * one-bits in its two's complement binary representation, that is, if it
 * is equal to zero.
 *
 * @return an {@code int} value with a single one-bit, in the position
 *     of the highest-order one-bit in the specified value, or zero if
 *     the specified value is itself equal to zero.
 * @since 1.5
 */
public static int highestOneBit(int i) {
    // HD, Figure 3-1
    i |= (i >>  1);
    i |= (i >>  2);
    i |= (i >>  4);
    i |= (i >>  8);
    i |= (i >> 16);
    return i - (i >>> 1);
}
Run Code Online (Sandbox Code Playgroud)

Bri*_*new 10

来自源代码顶部的评论......

   40    * <p>Implementation note: The implementations of the "bit twiddling"
   41    * methods (such as {@link #highestOneBit(int) highestOneBit} and
   42    * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are
   43    * based on material from Henry S. Warren, Jr.'s <i>Hacker's
   44    * Delight</i>, (Addison Wesley, 2002).
   45    *
Run Code Online (Sandbox Code Playgroud)

亨利·沃伦的黑客喜剧.