Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
cetlib
cetlib
test
bit_test.cc
Go to the documentation of this file.
1
#include "
cetlib/bit_manipulation.h
"
2
#include <cstdlib>
3
4
using
cet::bit_number;
5
using
cet::bit_size
;
6
using
cet::circ_lshift;
7
using
cet::left_bits;
8
using
cet::right_bits;
9
10
void
11
ensure
(
int
which,
bool
claim)
12
{
13
if
(not claim)
14
std::exit(which);
15
}
16
17
int
18
main
()
19
{
20
typedef
unsigned
int
uint
;
21
typedef
unsigned
long
ulong
;
22
23
ensure
(1,
bit_size<uint>::value
==
sizeof
(uint) * 8);
24
ensure
(2,
bit_size<ulong>::value
==
sizeof
(ulong) * 8);
25
26
ensure
(3,
bit_number<uint, 0>::value
== 1u);
27
ensure
(4,
bit_number<uint, 1>::value
== 2u);
28
ensure
(5,
bit_number<uint, 3>::value
== 8u);
29
30
ensure
(6,
right_bits<uint, 0>::value
== 1u);
31
ensure
(7,
right_bits<uint, 1>::value
== 3u);
32
ensure
(8,
right_bits<uint, 3>::value
== 15u);
33
34
ensure
(11,
35
(
left_bits<uint, 0>::value
^
uint
(-1)) ==
right_bits<uint, 32>::value
);
36
ensure
(12,
37
(
left_bits<uint, 1>::value
^
uint
(-1)) ==
right_bits<uint, 31>::value
);
38
ensure
(13,
39
(
left_bits<uint, 3>::value
^
uint
(-1)) ==
right_bits<uint, 29>::value
);
40
41
for
(uint
k
= 0, pow2 = 1;
k
!=
bit_size<uint>::value
; ++
k
, pow2 *= 2)
42
ensure
(21 +
k
, circ_lshift(1u,
k
) == pow2);
43
44
return
0;
45
46
}
// main()
main
int main()
Definition:
bit_test.cc:18
ensure
void ensure(int which, bool claim)
Definition:
bit_test.cc:11
ulong
unsigned long ulong
Definition:
qglobal.h:352
muoncounters.k
k
Definition:
muoncounters.py:27
cet::bit_size
struct bit_size<U>.
Definition:
bit_manipulation.h:18
submit_mcc.value
value
Definition:
submit_mcc.py:159
uint
unsigned uint
Definition:
qglobal.h:351
bit_manipulation.h
Generated by
1.8.11