Qualcomm Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
My understanding of the question =>If M is the string and N is the bits of length 'j' to be replaced in M at 'i' th position then (Assuming the position starts with '0')
ret_mask(int i, int j)
{
mask=0;
if (i>=j)
{
mask=(((1<<j)-1)<<i);
}
return mask;
}
To replace
mask=ret_mask(i,j)
M(M&~mask)|(N<<i);
Not sure I undrstood the qustion correctly...
- gaurav December 18, 2011N = the string
i = postion of the Mask
j = length of N
Mask = N << (j-i)