Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

unsigned int oddParitySet 3 ( unsigned int intArg, unsigned int startBit ) ; This function will determine the odd parity for a 3 - bit

unsigned int oddParitySet3(unsigned int intArg, unsigned int startBit);
This function will determine the odd parity for a 3-bit segment of intArg starting at bit startBit and set the parity bit (low-order bit) appropriately.
E.g., suppose intArg=6 and startBit =2. The 32 bit representation, from high to low, would be 29 zeros then 110. So, bits 2-0 are 110. To make the parity odd, you would set bit zero to 1.
The return value is the modified intArg, in this case it would be 29 zeros then 111 or a value of 7.
Do not convert intArg to a string and operate on that. Use only integers or unsigned integers.
Note: If the start bit is greater than 31 or less than 2, return a zero.
correct the following code accordingly to these directions:
unsigned int oddParitySet3(unsigned int intArg, unsigned int startBit){
if (startBit <3|| startBit >31){
return 0;
}
unsigned int threeBits =(intArg >>(startBit-1)) &0x7;
unsigned int oddParityBit =0;
for (int i =0; i <3; i++){
oddParityBit ^=(threeBits >> i) & 0x1;
}
intArg &= ~(1u <<(startBit -1));
intArg |=(oddParityBit <<(startBit -1));
return intArg;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

explain what is meant by redundancy

Answered: 1 week ago