ATLAS Offline Software
Public Member Functions | List of all members
Parity Class Reference

calculates the parity of a passed word More...

#include <Parity.h>

Collaboration diagram for Parity:

Public Member Functions

 Parity ()
 
 ~Parity ()
 
unsigned int even (unsigned int word) const
 returns even parity of passed word i.e. More...
 
unsigned int odd (unsigned int word) const
 returns the odd parity of the passed word i.e. More...
 

Detailed Description

calculates the parity of a passed word

Author
Edward Moyse

Definition at line 20 of file Parity.h.

Constructor & Destructor Documentation

◆ Parity()

Parity::Parity ( )

Definition at line 14 of file Parity.cxx.

14  {
15 }

◆ ~Parity()

Parity::~Parity ( )

Definition at line 16 of file Parity.cxx.

16  {
17 }

Member Function Documentation

◆ even()

unsigned int Parity::even ( unsigned int  word) const

returns even parity of passed word i.e.

0 returns 0 and 111 (7) returns 1

Definition at line 19 of file Parity.cxx.

19  {
20  unsigned int numOfBits=0;
21  for (unsigned int bit=0; bit<sizeof(word); bit++){
22  if (word&(1<<bit)) numOfBits++;
23  }
24  return (numOfBits%2);
25 }

◆ odd()

unsigned int Parity::odd ( unsigned int  word) const

returns the odd parity of the passed word i.e.

0 returns 1 and 111 (7) returns 0

Definition at line 27 of file Parity.cxx.

27  {
28  return (1-even(word) );
29 }

The documentation for this class was generated from the following files:
Parity::even
unsigned int even(unsigned int word) const
returns even parity of passed word i.e.
Definition: Parity.cxx:19