Skip to content

Instantly share code, notes, and snippets.

@ananich
ananich / gist:631f9d40d20ec3aa5104
Created Feb 12, 2015
java.lang.Integer.numberOfLeadingZeros (Java 8)
View gist:631f9d40d20ec3aa5104
/**
* Returns the number of zero bits preceding the highest-order
* ("leftmost") one-bit in the two's complement binary representation
* of the specified {@code int} value. Returns 32 if the
* specified value has no one-bits in its two's complement representation,
* in other words if it is equal to zero.
*
* <p>Note that this method is closely related to the logarithm base 2.
* For all positive {@code int} values x:
* <ul>
@ananich
ananich / gist:98310150db97f6edac28
Last active Aug 29, 2015
java.lang.Integer.numberOfLeadingZeros (in Assembler x86)
View gist:98310150db97f6edac28
CompilerOracle: print *Integer.numberOfLeadingZeros
Compiled method (c1) 1437 56 3 java.lang.Integer::numberOfLeadingZeros (76 bytes)
total in heap [0x000000010a826bd0,0x000000010a8270f0] = 1312
relocation [0x000000010a826cf8,0x000000010a826d30] = 56
main code [0x000000010a826d40,0x000000010a826f60] = 544
stub code [0x000000010a826f60,0x000000010a826ff0] = 144
metadata [0x000000010a826ff0,0x000000010a826ff8] = 8
scopes data [0x000000010a826ff8,0x000000010a827038] = 64
scopes pcs [0x000000010a827038,0x000000010a8270e8] = 176
dependencies [0x000000010a8270e8,0x000000010a8270f0] = 8