# What is total parity of bits?

• Callaghan
So, the XOR operation can generate a 1 by XORing a 1 with a 0, or a 0 with a 1. This is also known as an invert gate or a NOT gate. In summary, classical computing uses gates such as AND, OR, XOR, NAND, and NOR to perform logical operations on multiple bits. It has been proven that any function on bits can be computed using only NAND gates, making them a universal gate. However, the XOR gate alone or with NOT is not universal because it does not change the total parity of the bits. This means that an XOR gate cannot generate an odd number of 1's in the output. Therefore, gates such as AND, OR, NAND, and

#### Callaghan

Below is the extraction from quantum computer book, but I think my question is related to classical computing;

"Now let us generalize from one to multiple qubits. Figure 1.6 shows five notable multiple bit classical gates, the AND, OR, XOR (exclusive-OR ), NAND and NOR gates. An important theoretical result is that any function on bits can be computed from the composition of NAND gates alone, which is thus known as a universal gate. By contrast, the XOR alone or even together with NOT is not universal. One way of seeing this is to note that applying an XOR gate does not change the total parity of the bits. As a result, any circuit involving only NOT and XOR gates will, if two inputs x and y have the same parity, give outputs with the same parity, restricting the class of functions which may be computed, and thus precluding universality."

I searched over the dictionary and understood the meaning of universal gate, but I do not get the total parity of the bits.

What does that mean? and what does that underlined, bold sentence imply?

I searched, and I found parity bits, but it seems that it's little bit different from what I am looking for.

If you have N bits and M of them are one, then the "total parity" will depend only on "M". If M is odd, the "total parity" will be 1. If M is even, then "total parity" will be 0. The word "total" is not usually included - but they are probably referring to the fact that an XOR is the same as a modulo 2 addition.

Stepping back, they are trying to show that there are some gates that cannot be created with only XORs. They are also letting you use NOT - but this is no gift. You can generate a NOT from an XOR by XORing with 1. Starting with A, B, and as many XORs as you wish, these are the symbols you can generate:
0, A, B, A XOR B, 1, NOT A, NOT B, or NOT(A XOR B)

XORing any of those with any of the others will not generate anything new.
What they are getting at can be seen in the table below. The columns are:
1) Result when A=0, B=0
2) Result when A=0, B=1
3) Result when A=1, B=0
4) Result when A=1, B=1
5) The XOR operation generating the result.
0000 0
0011 A
0101 B
0110 A XOR B
1111 1
1100 NOT A
1010 NOT B
1001 NOT(A XOR B)

Here's the key. Notice two things:
1) For each row, the number of 1's in the the table above is always even.
2) Whenever you XOR two even patterns, you will get an even result.

Therefore, something like an AND, OR, NAND, or NOR can never be generated from XOR gates only.
0001 AND (1 is odd)
0111 OR (3 is odd)
1110 NAND (3 is odd)
1000 NOR (1 is odd)

Last edited:
• poseidon721 and jim mcnamara
So, I understand that the gate can be viewed as combination of 0 and 1 for 4 binary digits by using 0, A, B, 1.

But how do you make 1 by XOR??

Callaghan said:
So, I understand that the gate can be viewed as combination of 0 and 1 for 4 binary digits by using 0, A, B, 1.

But how do you make 1 by XOR??
In practice, you can always tie the input to a gate high or low. This is the same as providing a 1 or 0 as the input. So 1 and 0 are always available - unless you make a special rule to exclude them.

## What is total parity of bits?

Total parity of bits refers to the parity of all bits in a given data set, rather than just a single bit. It is used to ensure that the total number of 1s in a data set is either even or odd, depending on the type of parity being used.

## Why is total parity of bits important?

Total parity of bits is important because it helps to detect and correct errors in data transmission. By checking the parity of all bits in a data set, it is possible to determine if any bits have been flipped or changed during transmission.

## How is total parity of bits calculated?

Total parity of bits is calculated by counting the total number of 1s in a data set and determining if the count is even or odd. This can be done using a variety of mathematical operations, such as XOR or AND, depending on the type of parity being used.

## What types of parity can be used for total parity of bits?

The two main types of parity used for total parity of bits are even parity and odd parity. Even parity means that the total number of 1s in a data set must be even, while odd parity means that the total number of 1s must be odd.

## How is total parity of bits used in real-world applications?

Total parity of bits is commonly used in data storage and transmission systems, such as computer memory and communication protocols. It helps to ensure the accuracy and integrity of data by detecting and correcting errors that may occur during transmission.