blob: bcafd310a2129a00031f2e5ae67766a4a44c4a04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
class BuiltinBitCount
{
public static int popcount(int x)
{
return Integer.bitCount(x);
}
public static int popcountl(long x)
{
return Long.bitCount(x);
}
public static void main(String[] args)
{
if (Integer.bitCount(0) != 0)
throw new Error();
if (Integer.bitCount(8) != 1)
throw new Error();
if (Integer.bitCount(123456) != 6)
throw new Error();
if (Integer.bitCount(-1) != 32)
throw new Error();
if (Long.bitCount(0) != 0)
throw new Error();
if (Long.bitCount(8) != 1)
throw new Error();
if (Long.bitCount(123456) != 6)
throw new Error();
if (Long.bitCount(-1) != 64)
throw new Error();
if (popcount(0) != 0)
throw new Error();
if (popcount(8) != 1)
throw new Error();
if (popcount(123456) != 6)
throw new Error();
if (popcount(-1) != 32)
throw new Error();
if (popcountl(0) != 0)
throw new Error();
if (popcountl(8) != 1)
throw new Error();
if (popcountl(123456) != 6)
throw new Error();
if (popcountl(-1) != 64)
throw new Error();
}
}
|