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
What is a char in c?
Can a variable be both const and volatile?
Is it cc or c in a letter?
Tell us something about keyword 'auto'.
Can the “if” function be used in comparing strings?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
What is the difference between union and structure in c?
Difference between MAC vs. IP Addressing
Explain indirection?
What is wrong with this program statement?
What is a pragma?
Is swift based on c?
What are the 5 elements of structure?
What are shell structures used for?