Question: THIS IS THE FUNCTIONS C FILE /* * BitFunctions.c * */ #include BitManipulations.h //************************************************************************************/ // // invertBits // // Description:Accepts a pointer of size uint32_t
THIS IS THE FUNCTIONS C FILE /* * BitFunctions.c * */ #include "BitManipulations.h" //************************************************************************************/ // // invertBits // // Description:Accepts a pointer of size uint32_t and inverts // Each bit of the input data passed // Preconditions:input argument is passed as a pointer // Postconditions:the number of 1s returned // // Calls: N/A // Called by: main // //***********************************************************************************/ int countNumberofOnes(uint32_t *intData) { // Write a function that counts number of 1s in an integer passed } //***********************************************************************************/ //* //* setBit //* //* Description: The function sets the bit in the specified bit position in an to the specifid value. //* Preconditions: Value can be a 1 or 0. bitPosition will be between 0 and 31 (for integer size argument) //* Postconditions: The bit of *inData at position biPosition will be set to value //* //* Calls: N/A //* Called by: main //* //***********************************************************************************/ void setBit(uint32_t *inData, uint32_t bitPosition,uint32_t value) { // Please do not treat the integer as arrays , this question is about bit manipulations // You will need to use bitwise operations to solve this question } //***********************************************************************************/ //* hammingDistance //* Description: Function hammingDistance calculates total number of bits //* that need to be inverted in order to change inData1 into inData2 or vice versa. //* Preconditions: The function accepts two unsigned integers as input //* Postconditions: The function returns the hamming distance //* // Calls: N/A // Called by: main //* //***********************************************************************************/ int hammingDistance(uint32_t inData1, unint32_t inData2) { }
THIS IS THE BIT MANIPULATION C File
/* * BitManipulations.c * */ #include#include "BitManipulations.h" int main(int *argc, char **argv) { uint32_t Number; uint32_t bitPosition; uint32_t value; int numOnes; uint32_t input1; uint32_t input2; int32_t hDist; value = 1; bitPosition = 21; Number = 15345; numOnes = countNumberofOnes(&Number); setBit(&Number, bitPosition,value); // set bit in bitposition to value hDist = hammingDistance(input1, input2); // Calculates hamming distance printf(" Hamming Distance = %d \t number of Ones : %d ", hDist, numOnes); return 0; }
FINALLY, THIS IS THE HEADER FILE PROVIDED
/* * BitManipulations.h * */ #ifndef BITMANIPULATIONS_H_ #define BITMANIPULATIONS_H_ typedef unsigned int uint32_t; typedef unsigned short uint16_t; #endif /* BITMANIPULATIONS_H_ */
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
