Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Can a variable be both const and volatile?

1068


How do I create a directory? How do I remove a directory (and its contents)?

1090


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

2354


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1324


Explain how can I write functions that take a variable number of arguments?

1027


What is #include stdlib h?

1055


What is .obj file in c?

1017


How can I run c program?

1122


What is struct node in c?

1014


how to introdu5ce my self in serco

1936


What is meant by initialization and how we initialize a variable?

999


Explain what is wrong with this program statement?

1065


How can I find out if there are characters available for reading?

1053


Write a program of prime number using recursion.

1034


What does printf does?

1189