uthcode / learntosolveit

The C Programming Language Companion
http://www.learntosolveit.com
Other
209 stars 1.36k forks source link

Update Ex_2.6_setbits.c #140

Open attentiveanuj opened 2 years ago

attentiveanuj commented 2 years ago

the return statement is wrong it should be return x &((~0<<p+1) | ~(~0<<(p+1-n))) | ((y&~(~0<<n))<<(p+1-n));

attentiveanuj commented 2 years ago

the return statement is wrong try x = 16 p = 4 n = 4 y = 8 ans should be 16