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

An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1232


Why is struct padding needed?

1084


Subtract Two Number Without Using Subtraction Operator

846


What is a pointer in c plus plus?

1303


Explain how do you determine whether to use a stream function or a low-level function?

1082


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2690


What is operator precedence?

1204


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3253


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

1094


List some of the dynamic data structures in C?

1240


Why doesnt this code work?

1058


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

1119


Why clrscr is used in c?

1014


What is the difference between exit() and _exit() function?

1045


What is the difference between a string and an array?

1201