-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_parity.h
40 lines (33 loc) · 955 Bytes
/
compute_parity.h
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
#ifndef CPP_ALGORITHM_COMPUTE_PARITY_H
#define CPP_ALGORITHM_COMPUTE_PARITY_H
#include <array>
namespace ComputingParity
{
/**
* \brief Count the number of bits that are set to 1.
* \param x input number
* \return count of 1s
*/
auto CountBits(unsigned int x) -> short;
/**
* \brief Compute parity of word.
* \param x input number
* \return parity of word
*/
auto Parity(unsigned long long x) -> short;
/**
* \brief Compute parity by dropping the lowest set bit.
* \param x input number
* \return parity of word
*/
auto ParityDropLowestBits(unsigned long long x) -> short;
/**
* \brief Compute parity by caching the results.
* \param x input number
* \return parity of word
*/
auto ParityLookupTable(unsigned long long x) -> short;
// TODO: Implement ParityLookupTableXor
auto ParityXor(unsigned long long x) -> short;
}
#endif