Provided the Number is not zero Then
// representing number in some format //A contains the bits before the last one & B is after last one //small c after variable represent Compliments of that number like N & Nc Num=A1B //Some Property -N=Nc+1 Nc is compliment of N (-Num) =(A1B)c+1=Ac0Bc+1=Ac1B //{ 0Bc since Bc is all bit 1 adding 1 will give 1B} Num= A1B -Num=Ac1B //if we Ac&A will be zero and B&B will be zero too.. so , so remaining will be the last one (Num&(-Num)) //leave last single '1'Try this on you PC..
No comments:
Post a Comment