Mock Interview: Coding random 'Bit masking' Questions | Embedded systems podcast, in Pyjama

preview_player
Показать описание

𝗜𝗻 𝘁𝗵𝗶𝘀 𝘃𝗶𝗱𝗲𝗼: Mahmad was asked to solve two coding problems.

Questions:

𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Modify a range of bits of a given 32-bit register.
24:12 Minimum number of bit flips required to convert a number A into B.

𝙋𝙖𝙣𝙚𝙡 𝙈𝙚𝙢𝙚𝙗𝙚𝙧𝙨:

-----

#inpyjama #embeddedsystems #embedded #systemdesign #software #softwareengineering #embeddedpodcast
Рекомендации по теме
Комментарии
Автор

I will give you awesome trick to remember XOR. XOR is nothing but an Inequality detector. When two bits are not equal the XOR operator detect it otherwise not. Conversly, You can remember XNOR as an Equality detector.

yogeshchauhan
Автор

Valuable content, the likes of which have been missing specially for embedded domain. Please do keep with such content in future as well😊.

sushilsingh
Автор

Thank you guys for such a detailed explanation. Honestly, I did not know about builtin function like popcount that's supported by GCC compiler. Figured out there are couple of more functions like this while I goggled about the same.

emanivamsikrishna
Автор

This is Quality content !! Thanks for doing this!

tabrezahmed
Автор

Guys it’s a great series, we know that u people are attempting with any preparation, please continue the series & we need more questions in bit masking

poornachandumarneni
Автор

last problem
int num = a^b;
for(int i=0;i<8*sizeof(a);i++)
{
flag = ((num>>i) & 1)?1:0;
if(flag)
{
count++;
}
}
printf("number of bits: %d", count);

Please continue this series..Thanku!!!

Akash_
Автор

I think in first question where you have calculated "value to be written", we don't need mask. It can simply be x << m because x is smaller than 2^(n-m). Please correct me if I am wrong. But yes we need mask for putting that value in a.

bornmad
Автор

Why a and b are multiplied with 0x01 in line ax01 & bx01? To get the rightmost bit?

JgNt
Автор

We can also generate mask programmatically by doing 2^(m-n+1) to get a mask of 8 bits, OR it with desired value and then << m-1 for final mask, then OR it with input to set those bit range. Am I correct?

shankarsridhar
Автор

Need more info & questions on bit masking

poornachandumarneni