Returns 1 if x < y as unsigned longs, and 0 otherwise. Assumes that x - y fits into a signed long. The implementation is branch-free, and benchmarks suggest it is measurably faster than the straightforward ternary expression.
(long x, long y)
| 109 | */ |
| 110 | |
| 111 | @VisibleForTesting |
| 112 | static int lessThanBranchFree(long x, long y) { |
| 113 | // Returns the sign bit of x - y. |
| 114 | return (int) (~~ (x - y) >>> (Long.SIZE - 1)); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Returns the base-2 logarithm of {@code x}, rounded according to the specified rounding mode. |
no outgoing calls
no test coverage detected