CopyBits(x,p,n,y)
copy n LSBs from y to x starting LSB at 'p'th position.
Answer Posted / intfail
all the above answers are wrong...
never use loops. immediate rejection
CopyBits(x, p, n, y)
First get n bits from pos p from Y
bitsFromy = y >> (p-n+1) & (~(~0<<n))
Now, get a mask such that we can 0 out bits in x at pos p and n bits to the right
startpos = p -n +1
create a mask from (startpos, p)
mask = (~0 << p - startpos +1)<<startpos | ~(~0 << startpos)
Now, 0 out the the bits in the locations (starpos, p) in x
and apply the bits extracted from y
x = (x & mask) | (bitsFromy << startpos)
that is all it takes.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Differentiate between static and dynamic modeling.
What does nil mean in c?
What are the application of c?
What are structures and unions? State differencves between them.
Describe explain how arrays can be passed to a user defined function
How do you use a pointer to a function?
What are bitwise shift operators in c programming?
Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include
What is variable initialization and why is it important?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Can we access the array using a pointer in c language?
Is that possible to store 32768 in an int data type variable?
What does p mean in physics?
What does struct node * mean?
What is the advantage of using #define to declare a constant?