 # Hi I have a question about the Parity Flag. Help!

#1

Recently I read a book about Intel 8088.
but about how to calculate the probability of checking error corrently let me confuse.(62.5% and 75%)
so please give me a favor, Thanks a lot !!!

#2

That’s weird, indeed.

Also I can’t see why for both 0 and F “everything is great”…

#3

This isn’t really a C++ problem or a Pokitto problem, but I had a go anyway.

I’m not a very good mathematician,
but in all honesty, I think the book is wrong.

For one thing, @carbonacat is right,
`0` and `F` certainly wouldn’t put you in a better standing than any other value.

The section of the book you’ve captured doesn’t state whether it’s assuming an odd parity bit (i.e. `0` on odd and `1` on even) or an even parity bit (i.e. `1` on odd and `0` on even), but it seems that x86 uses an odd parity bit.

Case 1:
1 possible value with 0 `1` bits

• `0000`

For this the parity bit will be `1`

Case 2:
4 possible values with only 1 `1` bit

• `1000`
• `0100`
• `0010`
• `0001`

For these the parity bit will be `0`

Case 3:
6 possible values with only 2 `1` bits

• `1100`
• `0110`
• `0011`
• `1001`
• `1010`
• `0101`

For these the parity bit will be `1`

Case 4:
4 possible values with only 3 `1` bits

• `1110`
• `0111`
• `1011`
• `1101`

For these the parity bit will be `0`

Case 5:
1 possible values with 4 `1` bits

• `1111`

For this the parity bit will be `1`

So that’s 4 + 4 = 8 values where the bit will be `0` (i.e. odd),
and 1 + 6 + 1 = 8 values where the bit will be `1` (i.e. even),
for a total of 16 values.

Assume you’re checking for one of the odd values (e.g. `0001`), that gives you:

• 1 correct odd value
• 7 incorrect odd values
• 8 incorrect even values
• (and 0 correct even values)

That’s 15 incorrect values in total, but the parity flag will only catch 8 of those (the even values), giving you:

• an 8/16 (50%) chance of the parity bit detecting an error
• a 7/16 (43.75%) chance of the value having an error, but the parity bit not detecting it
• a 1/16 (6.25%) chance of the value having no error

It’s worth noting that the parity bit is useful if an odd number of bits are incorrect, but not if an even number of bits are incorrect.

E.g. if you transmit `0001` (odd parity) and one of the bits are incorrect, you get an even parity, but if two of the bits are incorrect, you get an odd parity

#4

The author of the book is not saying anything about the parity check mechanism and transmission protocol. Is this 4 bits + 1 parity bit, or some sort of a frame of data… hmm.

#5

Suppose that you only transmit 0000 or 1111, then if you receive something that hasnt 4 equal bits, you are sure that there have been transmission errors. Odds of detecting errors = 14/16.
Suppose that you only transmit 0001, 0010, 0100 or 1000: if 2 bit errors occur, you can no longer be certain to detecting them. Odds of detecting errors= 12/16=75%
For 0011, 1010,… Odds=10/16=62.5%
I am typing this on my mobile so sorry if this explanation is cryptic

#6

That’s not how the parity bit works though.
The parity bit is an XOR of all the bits (or an inversion of that).
I.e. `bit0 ^ bit1 ^ bit2 ^ bit3` (or `~(bit0 ^ bit1 ^ bit2 ^ bit3)`)

So for `0000` it’s `0` (or `1`), and for `1111` it’s also `0` (or `1`).

That’s the odds of the number not being one of the 4 values you’re transmitting, not the odds of detecting the error.

That might explain how the author made the mistake though.

#7

To be clear: I just tried to get the same results as the author. I know how a parity bit works

#8

What a confusing book, TBH I spent some time on this but never came to understand the exact though process of the author. Maybe a context in which this is discussed would help? As @jonne says, we’ve not been given details on the transmission channel properties etc.

#9

Thanks everyone! Thats my thought. I think only two cases, and all is 56.25%.

Thats the book.