Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/careercup/ctci
/ sign
Method
sign
java/Chapter 17/Question17_4/Question.java:10–12 ·
view source on GitHub ↗
(int a)
Source
from the content-addressed store, hash-verified
8
9
/* Returns 1
if
a is positive, and 0
if
a is negative */
10
public
static
int
sign(
int
a) {
11
return
flip((a >> 31) & 0x1);
12
}
13
14
public
static
int
getMaxNaive(
int
a,
int
b) {
15
int
k = sign(a - b);
Callers
2
getMaxNaive
Method · 0.95
getMax
Method · 0.95
Calls
1
flip
Method · 0.95
Tested by
no test coverage detected