Questions tagged [parity]

A parity bit, or check bit, is a bit that is added to ensure that the number of bits with the value one in a set of bits is even or odd. Parity bits are used as the simplest form of error detecting code.

A parity bit, or check bit, is a bit that is added to ensure that the number of bits with the value one in a set of bits is even or odd. Parity bits are used as the simplest form of error detecting code.

There are two variants of parity bits: even parity bit and odd parity bit. In case of even parity, the parity bit is set to 1, if the number of ones in a given set of bits (not including the parity bit) is odd, making the number of ones in the entire set of bits (including the parity bit) even. If the number of ones in a given set of bits is already even, it is set to a 0. When using odd parity, the parity bit is set to 1 if the number of ones in a given set of bits (not including the parity bit) is even, keeping the number of ones in the entire set of bits (including the parity bit) odd. when the number of set bits is odd, then the odd parity bit is set to 0.[1]

236 questions
-2
votes
1 answer

5-bit odd parity checker

I am trying to code a 5-bit Mealy odd parity checker. I got some of the code written (the reset, the next state logic, and the output logic) except the part where the checking happens for the 5-bit output. How can I check a 5-bit variable if the…
Jordan
  • 1
  • 3
-2
votes
1 answer

How to extend binary with Scala?

I am trying to complete the below exercise: I have attempted it below, but my code is not acting as expected. def extend(p: Long): Long = { var e = p.toBinaryString if ( e.count(_== '1') % 2 == 0) { e="0"+e }else { e="1"+e } …
S.H
  • 33
  • 5
-2
votes
5 answers

How to find if there is a even or a odd number of "1" bit

Is it possible to say if there is a even or a odd number of "1" bit in a binary representation of an int in C with a single test ? If no what is the fastest way to do it ?
RIAN
  • 1
  • 1
  • 1
-2
votes
1 answer

How do I represent an integer in binary so I can compare using XOR?

I have to create a code that takes 1-6 bits of binary, stuffs the most significant bits with 0 if the string isn't 6 already and compare 2 packets of 3 bits using the XOR operation. The outputs are weird, I think its because I'm comparing the…
-2
votes
1 answer

Even/Odd parity for Even/Odd values

It might just be that I don't fully understand parity bits, but would it make sense to do an even parity for even values and an odd parity for odd values to add an extra level of redundancy without adding extra bits? Or would that negate the parity.
user3727843
  • 574
  • 1
  • 4
  • 13
-2
votes
1 answer

Python XOR on hex and string (parity check function)

I am running into problems with Hex values and python. I am trying to write a function which performs a bytewise XOR and returns a Hex value. Basically I am trying to convert this C# code to Python: private byte[] AddParity(string _in) { byte…
Ronald
  • 17
  • 1
  • 6
-3
votes
1 answer

This is a question from computer networks paper to calculate number of errors can be detected in a word using even parity bit

Question A communication system uses even parity and adds a parity bit to each seven bit. Thus a word(8mbits) transmitted consists of 7 data bits and one parity bit. How many errors can it detect in a word?
Lak
  • 1
  • 3
-3
votes
3 answers

Counting the occurrences of a character in each element of a list

lst = ['10010001','01101001'] I need to count the number of times the number '1' appears in each element
-5
votes
3 answers

Is zero (0) an even or odd number?

Not a request for code of any type. Let's say you are randomly generating a number between zero and ten and are doing so until you receive just an even number. Is zero an available result? Are the evens 0-10: 2, 4, 6, 8, 10 -OR- 0, 2, 4, 6, 8, 10
user3223880
  • 65
  • 1
  • 10
-5
votes
2 answers

How to calculate parity of a 32bits number in assembly?

I need to calculate the parity of a 32 bits number and return it. To do this I must use XOR, SHR,SETP(or similar) and movzx. Somebody have an idea ?
ant1
  • 191
  • 15
-8
votes
3 answers

How to add parity bits on c#

Please help I want c# to come up with this once it comes up Please enter a 7-bit binary number: 0010011 Your number with a parity bit is: 00100111 This is my code that I have come up with, its probably wrong please can you correct it so it is…
user1726553
  • 13
  • 2
  • 7
1 2 3
15
16