for example, the JDK method java.lang.Integer.numberOfLeadingZeros(int):
例如,JDK方法java.lang.Integer.numberOfLeadingZeros(int):
public static int numberOfLeadingZeros(int i) {
// HD, Figure 5-6
if (i == 0)
return 32;
int n = 1;
if (i >>> 16 == 0) { n += 16; i <<= 16; }
if (i >>> 24 == 0) { n += 8; i <<= 8; }
if (i >>> 28 == 0) { n += 4; i <<= 4; }
if (i >>> 30 == 0) { n += 2; i <<= 2; }
n -= i >>> 31;
return n;
}
what does the code comment 'HD, Figure 5-6' mean?
代码注释“HD,图5-6”是什么意思?
1 个解决方案
#1
5
HD = Hacker's Delight. See the the javadoc:
高清=黑客的喜悦。看到javadoc:
Implementation note: The implementations of the "bit twiddling" methods (such as
highestOneBit
andnumberOfTrailingZeros
) are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).实现说明:“位旋转”方法(如highestOneBit和numberOfTrailingZeros)的实现基于小亨利·s·沃伦(Henry s . Warren, Jr.)的《黑客的喜悦》(Addison, 2002)。
#1
5
HD = Hacker's Delight. See the the javadoc:
高清=黑客的喜悦。看到javadoc:
Implementation note: The implementations of the "bit twiddling" methods (such as
highestOneBit
andnumberOfTrailingZeros
) are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).实现说明:“位旋转”方法(如highestOneBit和numberOfTrailingZeros)的实现基于小亨利·s·沃伦(Henry s . Warren, Jr.)的《黑客的喜悦》(Addison, 2002)。