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

Convert hex strings to integers

Visual Basic 2010: Recently in one of my projects I have been tasked with reading several data fields in hex. Each field is three characters long. So this is what I have been doing: 'Read the hex value and convert it to decimal Dim hexVal as string …
sinDizzy
  • 1,300
  • 7
  • 28
  • 60
2
votes
1 answer

Serial Comms baud rate, parity and stop bits. Which options to use and when?

I'm trying to pick up some serial comms for a new job I am starting. I have done some reading which has helped a lot however, a lot of the reading tells you about the specification of serial comms and what everything is, but not when is best to use…
user3103055
  • 35
  • 1
  • 6
2
votes
2 answers

How to check a BCH(15,11,1) code/checksum for BDS/Beidou satellite system

In the PDF http://www.beidou.gov.cn/attach/2012/12/27/201212273da29c5eb8274deb8cd2b178228ba2bd.pdf chapter 5 (pages 9ff) the BCH(15,11,1) code for Beidou system is described. I'm trying to implement usage of this code for error checking (i.e. I only…
Dirk Stöcker
  • 1,628
  • 1
  • 12
  • 23
2
votes
1 answer

C# serial rs232 parity error

I'm trying to get a simple serial reader going in C# to read info from an rs232. I'm using VS2008. I can receive data fine with HyperTerminal and python but I keep getting parity errors every time I try to transmit a character to C#. Number's work…
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
2
votes
2 answers

Even parity of a unsigned int

/*A value has even parity if it has an even number of 1 bits. *A value has an odd parity if it has an odd number of 1 bits. *For example, 0110 has even parity, and 1110 has odd parity. *Return 1 iff x has even parity. */ int…
user2917692
  • 147
  • 1
  • 3
  • 10
2
votes
1 answer

int bitparity's explaination

I have to create a function bitParity(int x) that takes an integer and returns 1 if there is an odd number of 0's in the bit form of x, and 0 otherwise. Ex: bitParity(5) = 0, bitParity(7) = 1 Legal ops: ! ~ & ^ | + << >> My buddy shared his code…
2
votes
2 answers

Cortex-A9 Cache Parity

I'm using a cortex-a9 based design ( Altera Cyclon-V ) with a pl310 l2 cache controller. When I'm enabling the "parity enabled" in the PL310 AUX register, I get failures ( interrupt indicating cache parity issue ) . When I'm keeping Parity…
user3087632
  • 143
  • 2
  • 9
2
votes
1 answer

PARMRK termios behavior not working on Linux

I'm trying to receive messages from a device that uses mark parity for an address byte and space parity for the message body. The device is a "master" of a multi-drop serial bus. Based on the termios man page, I am using CMSPAR, PARENB, ~PARODD,…
Dan George
  • 51
  • 1
  • 6
2
votes
1 answer

Parity flag for value of 0 in x86

I see that in x86 CPUs, the parity flag (PF) is set when the number of bits set to 1 is even, and that only the first byte (lower 8 bits) of a value are ever tested. The only case I am not sure about is when we are dealing with a value of 0. I have…
alt.126
  • 1,097
  • 1
  • 9
  • 22
2
votes
2 answers

Calculating parity bit with the preprocessor (parity functional style with call by ref)

Consider I want to generate parities at compile time. The parity calculation is given literal constants and with any decent optimizer it will boil down to a single constant itself. Now look at the following parity calculation with the C…
slartibartfast
  • 641
  • 4
  • 12
1
vote
3 answers

How to add even parity bit on 7-bit binary number

I am continuing from my previous question. I am making a c# program where the user enters a 7-bit binary number and the computer prints out the number with an even parity bit to the right of the number. I am struggling. I have a code, but it says…
user1176925
1
vote
3 answers

C# Parity Bits from a Binary Number

Possible Duplicate: How to add even parity bit on 7-bit binary number This is my new code which converts a 7-bit binary number to an 8-bit with even parity. However it does not work. When I type in 0101010 for example, it says the number with…
user1176925
1
vote
2 answers

I have a program in c that doesn't work as it should with parity very well

My code doesn't display matrices larger than n>1 #include #include #include #define MAX_N 10 int n; int matrix[MAX_N][MAX_N]; bool used[MAX_N * MAX_N + 1]; int count = 0; bool check(int row, int col, int val) { …
1
vote
0 answers

Can FileInputStream.read read an odd number of bytes?

I have a method that reads a 16 bit WAVE file, like this: FileInputStream in = new FileInputStream(file); byte[] bytes = new byte[8*Number]; do { readSize = in.read(bytes, 0, 8*Number); ... } while (...); I then need to convert each pair of…
Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58
1
vote
1 answer

Permutation sign for batched vectors - Python

I would like to find the permutation parity sign for a given batch of vectors (in Python /Jax). n = jnp.array([[[0., 0., 1., 1.], [0., 0., 1., 1.], [1., 1., 0., 0.], [1., 1., 0., 0.]], …
relaxon
  • 141
  • 6