Hi,
Could you please refresh my memory and explane those arguments ?
1. y = x & ~(1<<n) ( x=2 ,n=3)
2. y = ~x & (x+1)
3. a<<=1 ( a is define as int )
4. b>>=1 ( b is define as int )
Thanks in advanced
Hi,
Could you please refresh my memory and explane those arguments ?
1. y = x & ~(1<<n) ( x=2 ,n=3)
2. y = ~x & (x+1)
3. a<<=1 ( a is define as int )
4. b>>=1 ( b is define as int )
Thanks in advanced
& means mask, or turn one bit on in the result if the same bit is on for both arguments.
~ means flip the bits
>>= means shift this value to the right N places and assign the new value. In other words, the value should get smaller as you move left by 2^N
<<= means shift this value to the left N places and assign the new value. In other words, the value should get larger as you move right by 2^N
Last edited by whiteflags; 07-07-2014 at 04:09 AM.
Sorry, but homework is most often the settings where folks are asked to explain expressions like these. That puts you at odds with the site's homework policy, here.
Try giving the best explanation you can - yourself (i.e. show more effort than just copying questions to a forum). If you get things wrong, folks will be more inclined to help.