MCPcopy Create free account
hub / github.com/antlr/codebuff / lessThanBranchFree

Method lessThanBranchFree

output/java_guava/1.4.16/LongMath.java:111–115  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 4

log2Method · 0.95
log10Method · 0.95
log10FloorMethod · 0.95
sqrtMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected