Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

toggle a bit at ith positon [duplicate]

Possible Duplicate:
How do you set, clear and toggle a single bit in C?

Can some one help me how to toggle a bit at ith position. One way is to do ((n>>i) ^ 1) << i. Are there any other ways ?

like image 740
brett Avatar asked Sep 10 '10 01:09

brett


1 Answers

n ^= 1U << i is easy enough, isn't it?

like image 195
Stephen Canon Avatar answered Sep 28 '22 05:09

Stephen Canon